use new url name

This commit is contained in:
virusdefender 2017-12-06 11:07:25 +08:00
parent 003be998cd
commit 3c4f5b3933
2 changed files with 6 additions and 10 deletions

View File

@ -19,8 +19,8 @@ services:
- /data/log:/log
- $PWD/server:/code:ro
environment:
- service_discovery_url=http://127.0.0.1:8000/api/judge_server_heartbeat
- service_url=http://127.0.0.1:12358
- backend_url=http://backend:8000/api/judge_server_heartbeat
- service_url=http://judge-server:12358
- TOKEN=YOUR_TOKEN_HERE
ports:
- "0.0.0.0:12358:8080"

View File

@ -11,17 +11,13 @@ from utils import server_info, logger, token
class JudgeService(object):
def __init__(self):
self.service_url = os.environ.get("service_url")
self.service_discovery_url = os.environ.get("service_discovery_url")
if not self.service_url or not self.service_discovery_url:
raise JudgeServiceError("service url or service discovery url not set")
self.service_url = os.environ["service_url"]
self.backend_url = os.environ["backend_url"]
def _request(self, data):
try:
r = requests.post(self.service_discovery_url, data=json.dumps(data),
headers={"X-JUDGE-SERVER-TOKEN": token,
"Content-Type": "application/json"}, timeout=5).json()
r = requests.post(self.backend_url, json=data,
headers={"X-JUDGE-SERVER-TOKEN": token}, timeout=5).json()
except Exception as e:
logger.exception(e)
raise JudgeServiceError(e.message)