mirror of
https://github.com/QingdaoU/JudgeServer.git
synced 2025-11-04 14:50:01 +08:00
use new url name
This commit is contained in:
parent
003be998cd
commit
3c4f5b3933
@ -19,8 +19,8 @@ services:
|
|||||||
- /data/log:/log
|
- /data/log:/log
|
||||||
- $PWD/server:/code:ro
|
- $PWD/server:/code:ro
|
||||||
environment:
|
environment:
|
||||||
- service_discovery_url=http://127.0.0.1:8000/api/judge_server_heartbeat
|
- backend_url=http://backend:8000/api/judge_server_heartbeat
|
||||||
- service_url=http://127.0.0.1:12358
|
- service_url=http://judge-server:12358
|
||||||
- TOKEN=YOUR_TOKEN_HERE
|
- TOKEN=YOUR_TOKEN_HERE
|
||||||
ports:
|
ports:
|
||||||
- "0.0.0.0:12358:8080"
|
- "0.0.0.0:12358:8080"
|
||||||
|
|||||||
@ -11,17 +11,13 @@ from utils import server_info, logger, token
|
|||||||
|
|
||||||
class JudgeService(object):
|
class JudgeService(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.service_url = os.environ.get("service_url")
|
self.service_url = os.environ["service_url"]
|
||||||
self.service_discovery_url = os.environ.get("service_discovery_url")
|
self.backend_url = os.environ["backend_url"]
|
||||||
|
|
||||||
if not self.service_url or not self.service_discovery_url:
|
|
||||||
raise JudgeServiceError("service url or service discovery url not set")
|
|
||||||
|
|
||||||
def _request(self, data):
|
def _request(self, data):
|
||||||
try:
|
try:
|
||||||
r = requests.post(self.service_discovery_url, data=json.dumps(data),
|
r = requests.post(self.backend_url, json=data,
|
||||||
headers={"X-JUDGE-SERVER-TOKEN": token,
|
headers={"X-JUDGE-SERVER-TOKEN": token}, timeout=5).json()
|
||||||
"Content-Type": "application/json"}, timeout=5).json()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(e)
|
logger.exception(e)
|
||||||
raise JudgeServiceError(e.message)
|
raise JudgeServiceError(e.message)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user