| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #!/bin/sh
- #
- # WyOJ judger entrypoint.
- #
- # Writes .conf.json (which judge_client/init() requires) from the environment,
- # makes sure the runtime directories exist, then runs judge_client in the
- # foreground so that its output lands in `docker logs`.
- set -e
- cd /opt/uoj/judger
- mkdir -p uoj_judger/work uoj_judger/result uoj_judger/data log /var/uoj_data_copy
- # data/ is expected to be a symlink to /var/uoj_data_copy. The build context
- # normally excludes it, so recreate it here.
- if [ ! -e uoj_judger/data ]; then
- ln -s /var/uoj_data_copy uoj_judger/data
- fi
- chmod -R 777 uoj_judger/work uoj_judger/result log 2>/dev/null || true
- python3 - <<'PY'
- import json, os
- conf = {
- 'uoj_protocol': os.environ.get('UOJ_PROTOCOL', 'http'),
- 'uoj_host': os.environ.get('UOJ_HOST', 'uoj-web'),
- 'judger_name': os.environ.get('JUDGER_NAME', 'main_judger'),
- 'judger_password': os.environ.get('JUDGER_PASSWORD', '_judger_password_'),
- 'socket_port': int(os.environ.get('JUDGER_SOCKET_PORT', '2333')),
- 'socket_password': os.environ.get('JUDGER_SOCKET_PASSWORD', '_judger_socket_password_'),
- }
- with open('.conf.json', 'w') as f:
- json.dump(conf, f, indent=2)
- f.write('\n')
- print('wrote .conf.json: judger=%s -> %s://%s, socket :%d'
- % (conf['judger_name'], conf['uoj_protocol'], conf['uoj_host'], conf['socket_port']))
- PY
- echo "==> starting judge_client (foreground)"
- exec ./judge_client
|