oj-docs/src/JudgeServer/English/deploy.md

73 lines
1.4 KiB
Markdown
Raw Normal View History

2016-10-10 12:22:49 +00:00
# Deploy
2016-10-10 12:21:44 +00:00
Reuqirements:
2016-10-05 05:46:57 +00:00
2016-10-10 12:21:44 +00:00
- docker >= 1.12
- docker-compose >= 1.8
2016-10-05 05:46:57 +00:00
2016-10-10 12:21:44 +00:00
Three environment variables below must be set manully in `docker-compose.yml`
2016-10-05 05:46:57 +00:00
- `service_discovery_url`
- `judger_token`
- `service_url`
2016-10-10 12:21:44 +00:00
`judge_server` will send heartbeat request to `service_discovery_url`.
2016-10-05 05:46:57 +00:00
2016-10-10 12:21:44 +00:00
`service_url` is used to tell server to send task to this url(`judge_server`).
2016-10-05 05:46:57 +00:00
Example of `docker-compose.yml`
```yml
2016-10-10 12:21:44 +00:00
version: "2"
services:
judge_server:
image: judge_server
cpu_quota: 90000
read_only: true
tmpfs:
- /tmp
- /judger_run
- /spj
volumes:
- /data/JudgeServer/tests/test_case:/test_case:ro
- /data/log:/log
- /data/JudgeServer:/code:ro
environment:
- judger_token=token
- service_discovery_url=https://onlinejudge.me/service
- service_url=http://1.2.3.4:12358
ports:
- "0.0.0.0:12358:8080"
2016-10-05 05:46:57 +00:00
```
2016-10-07 12:41:27 +00:00
# Heartbeat request
2016-10-05 05:46:57 +00:00
2016-10-10 12:21:44 +00:00
- Method `POST`
- `X-JUDGE-SERVER-TOKEN`: `sha256(token)`
- `Content-Type`: `application/json`
2016-10-05 05:46:57 +00:00
Request data
```js
{
"judger_version": "2.0.1",
"hostname": "c45acd557074",
"cpu_core": 1,
"memory": 30.3,
"action": "heartbeat",
"cpu": 0,
"service_url": null or "http://1.2.3.4:8005"
}
```
If everything is OK, you should give a JSON response as follows
```js
{
"data": "success",
"err": null
}
```