2026/3/19更新
Step1)安裝Judge伺服器
jang@$ sudo apt install python3-dev python3-pip build-essential libseccomp-dev -y
jang@$ . dmojsite/bin/activate
(dmojsite)jang@$ git clone --recursive https://github.com/DMOJ/judge-server.git
(dmojsite)jang@$ cd judge-server
(dmojsite)jang@$ pip install -e .
Step2)設定id與key
登入DMOJ的管理者,點選「線上裁判 -> 裁判伺服器」,新增Judge主機的Name與讓DMOJ產生key,如下圖
將Judge主機的Name與key填入/home/jang/site/judge.yml的id與key,如下範例。
(dmojsite) jang@$ nano /home/jang/site/judge.yml
id: jian
key: "uB3ehed:g+q#;LYa;-rN<z#Cxxxxxxxxxxxxxxxxxxxxxxxx"
Step3)使用dmoj-autoconf產生runtime的設定,貼到/home/jang/site/judge.yml的最後。
(dmojsite) jang@ dmoj-autoconf
runtime:
as_x64: /usr/bin/x86_64-linux-gnu-as
as_x86: /usr/bin/as
awk: /usr/bin/mawk
cat: /usr/bin/cat
g++: /usr/bin/g++
g++11: /usr/bin/g++
g++14: /usr/bin/g++
g++17: /usr/bin/g++
gcc: /usr/bin/gcc
gcc11: /usr/bin/gcc
ld_x64: /usr/bin/x86_64-linux-gnu-ld
ld_x86: /usr/bin/ld
perl: /usr/bin/perl
python3: /home/jang/dmojsite/bin/python3
sed: /usr/bin/sed
Step4)在dmoj/local_settings.py最後一行新增「DMOJ_PROBLEM_DATA_ROOT = '/home/jang/site/problems'」,出題時題目測資會上傳到此資料夾
建立資料夾/home/jang/site/problems
(dmojsite) jang@$ mkdir /home/jang/site/problems
(dmojsite) jang@$ nano /home/jang/site/dmoj/local_settings.py
(dmojsite) jang@$ sudo supervisorctl restart site
Step5)在judge.yml使用problem_storage_globs設定測資資料夾,資料夾下需要有該題測資,該題目才會有此judge server。
完整judge.yml如下
Step6)執行Judge Server,使用不是root的使用者,進入dmojsite虛擬環境,執行「dmoj -c judge.yml localhost」啟動Judge Server
jang$ . /home/jang/dmojsite/bin/activate
(dmojsite) jang$ dmoj -c judge.yml localhost
出現綠色勾勾表示,DMOJ連到此Judge Server
Step7)使用Supervisor啟動Judge Server
編輯/etc/supervisor/conf.d/judge.conf,如下
(dmojsite) jang$sudo nano /etc/supervisor/conf.d/judge.conf
dmoj不能使用root執行,指定使用其他使用者,檢查資料夾路徑與使用者名稱是否需要修改。
$ sudo supervisorctl update
$ sudo supervisorctl restart judge
$ sudo supervisorctl status