simpily server url

This commit is contained in:
virusdefender 2017-11-25 13:55:45 +08:00
parent 0be7e76a53
commit 4b04ba4ef4

View File

@ -11,20 +11,11 @@ from utils import server_info, logger, token
class JudgeService(object):
def __init__(self):
# this container's ip and port, if these are not set, web server will think it's a linked container
self.service_url = os.environ.get("service_url")
self.service_discovery_url = os.environ.get("service_discovery_url")
# exists if docker link oj_web_server:oj_web_server
self.service_discovery_host = os.environ.get("OJ_WEB_SERVER_PORT_8080_TCP_ADDR")
self.service_discovery_port = os.environ.get("OJ_WEB_SERVER_PORT_8080_TCP_PORT")
self.service_discovery_url = os.environ.get("service_discovery_url", "")
if not self.service_discovery_url:
if not (self.service_discovery_host and self.service_discovery_port):
raise JudgeServiceError("service discovery host or port not found")
else:
self.service_discovery_url = "http://" + self.service_discovery_host + ":" + \
str(self.service_discovery_port) + "/api/judge_server_heartbeat/"
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):
try: