Skip to content
This repository has been archived by the owner on Nov 11, 2019. It is now read-only.

Add worker id #25

Merged
merged 7 commits into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions grader/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@

def get_url(endpoint):
return "{}://{}:{}{}{}".format("https" if USE_SSL else "http", API_HOSTNAME, API_PORT, API_PROXY, endpoint)


def print_usage():
print(
"Wrong number of arguments provided. Usage:\n\tpython grader.py <cluster token> <worker id>"
)
18 changes: 12 additions & 6 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import socket
import sys
import time
import argparse
from concurrent.futures import ThreadPoolExecutor, wait, FIRST_COMPLETED
from logging.handlers import TimedRotatingFileHandler

Expand All @@ -13,7 +14,7 @@

import grader.api_keys as api_key
from config import *
from grader.utils import get_url, print_usage
from grader.utils import get_url

# globals
worker_id = None
Expand Down Expand Up @@ -164,16 +165,21 @@ def register_node():
logger.info("Server response did not include heartbeat, using default {}".format(heartbeat_interval))


def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("token", help="Broadway cluster token")
parser.add_argument("worker_id", metavar="worker-id", help="Unique worker id for registration")
return parser.parse_args()


if __name__ == "__main__":
# check valid usage
if len(sys.argv) != 3:
print_usage()
exit(-1)
args = parse_args()

signal.signal(signal.SIGINT, signal_handler)

token = sys.argv[1]
worker_id = sys.argv[2]
token = args.token
ayushr2 marked this conversation as resolved.
Show resolved Hide resolved
worker_id = args.worker_id
hostname = socket.gethostname()

# register node to server
Expand Down