def main(augur_url, host, port): """ Declares singular worker and creates the server and flask app that it will be running on """ app = Flask(__name__) #load credentials broker_host = read_config("Server", "host", "AUGUR_HOST", "0.0.0.0") broker_port = read_config("Server", "port", "AUGUR_PORT", 5000) database_host = read_config('Database', 'host', 'AUGUR_DB_HOST', 'host') worker_info = read_config('Workers', 'repo_info_worker', None, None) worker_port = worker_info['port'] if 'port' in worker_info else port while True: try: r = requests.get("http://{}:{}/AUGWOP/heartbeat".format( host, worker_port)).json() if 'status' in r: if r['status'] == 'alive': worker_port += 1 except: break logging.basicConfig(filename='worker_{}.log'.format(worker_port), filemode='w', level=logging.INFO) config = { "id": "com.augurlabs.core.repo_info_worker.{}".format(worker_port), 'location': 'http://{}:{}'.format( read_config('Server', 'host', 'AUGUR_HOST', 'localhost'), worker_port), 'gh_api_key': read_config('Database', 'key', 'AUGUR_GITHUB_API_KEY', 'key') } #create instance of the worker app.worker = RepoInfoWorker( config ) # declares the worker that will be running on this server with specified config create_server(app, None) logging.info("Starting Flask App with pid: " + str(os.getpid()) + "...") app.run(debug=app.debug, host=host, port=worker_port) if app.worker._child is not None: app.worker._child.terminate() try: requests.post('http://{}:{}/api/unstable/workers/remove'.format( server['host'], server['port']), json={"id": config['id']}) except: pass logging.info("Killing Flask App: " + str(os.getpid())) os.kill(os.getpid(), 9)
def main(): """ Declares singular worker and creates the server and flask app that it will be running on """ app = Flask(__name__) app.worker = GitLabIssuesWorker() create_server(app) WorkerGunicornApplication(app).run() if app.worker._child is not None: app.worker._child.terminate() try: requests.post('http://{}:{}/api/unstable/workers/remove'.format(broker_host, broker_port), json={"id": config['id']}) except: pass os.kill(os.getpid(), 9)
def main(): """ Creates the Flask app and data collection worker, then starts the Gunicorn server """ app = Flask(__name__) app.worker = ClusteringWorker() create_server(app) WorkerGunicornApplication(app).run() if app.worker._child is not None: app.worker._child.terminate() try: requests.post('http://{}:{}/api/unstable/workers/remove'.format(broker_host, broker_port), json={"id": config['id']}) except: pass os.kill(os.getpid(), 9)
def main(): """ Declares singular worker and creates the server and flask app that it will be running on """ app = Flask(__name__) app.worker = GitlabMergeRequestWorker( ) # declares the worker that will be running on this server with specified config create_server(app, None) WorkerGunicornApplication(app).run() if app.worker._child is not None: app.worker._child.terminate() try: requests.post('http://{}:{}/api/unstable/workers/remove'.format( broker_host, broker_port), json={"id": config['id']}) except: pass logging.info("Killing Flask App: " + str(os.getpid())) os.kill(os.getpid(), 9)