mirror of
https://github.com/QingdaoU/JudgeServer.git
synced 2024-12-28 21:31:43 +00:00
使用token文件
This commit is contained in:
parent
32e0ab4516
commit
0dd7bc2ae5
2
.gitignore
vendored
2
.gitignore
vendored
@ -68,3 +68,5 @@ docker-compose.yml
|
||||
rsyncd.passwd
|
||||
|
||||
node_modules/
|
||||
|
||||
token.txt
|
||||
|
@ -19,8 +19,8 @@ services:
|
||||
- $PWD/tests/test_case:/test_case:ro
|
||||
- /data/log:/log
|
||||
- $PWD/server:/code:ro
|
||||
- $PWD/token.txt:/token.txt
|
||||
environment:
|
||||
- judger_token=token
|
||||
- service_discovery_url=https://virusdefender.net/service.php
|
||||
- service_url=http://1.2.3.4:12358
|
||||
ports:
|
||||
|
@ -22,3 +22,4 @@ SPJ_SRC_DIR = "/spj"
|
||||
SPJ_EXE_DIR = "/spj"
|
||||
|
||||
COUNTER_FILE_PATH = "/tmp/counter"
|
||||
TOKEN_FILE_PATH = "/token.txt"
|
||||
|
@ -3,4 +3,5 @@ chown compiler:compiler /spj
|
||||
echo 0 > /tmp/counter
|
||||
core=$(grep --count ^processor /proc/cpuinfo)
|
||||
n=$(($core*4))
|
||||
chmod 400 /token.txt /tmp/counter
|
||||
gunicorn --workers $n --threads $n --error-logfile /log/gunicorn.log --time 600 --bind 0.0.0.0:8080 server:wsgiapp
|
@ -8,7 +8,7 @@ import fcntl
|
||||
import hashlib
|
||||
import os
|
||||
|
||||
from config import COUNTER_FILE_PATH
|
||||
from config import COUNTER_FILE_PATH, TOKEN_FILE_PATH
|
||||
from exception import JudgeClientError
|
||||
|
||||
|
||||
@ -58,10 +58,11 @@ def server_info():
|
||||
|
||||
|
||||
def get_token():
|
||||
token = os.environ.get("OJ_WEB_SERVER_ENV_judger_token") or os.environ.get("judger_token")
|
||||
if not token:
|
||||
raise JudgeClientError("judger_token not set")
|
||||
return token
|
||||
try:
|
||||
with open(TOKEN_FILE_PATH, "r") as f:
|
||||
return f.read()
|
||||
except IOError:
|
||||
raise JudgeClientError("token.txt not found")
|
||||
|
||||
|
||||
token = hashlib.sha256(get_token()).hexdigest()
|
||||
|
0
token.example.txt
Normal file
0
token.example.txt
Normal file
Loading…
Reference in New Issue
Block a user