From 7f17c6da24fc84ee6df44d06e8611779deaaf91a Mon Sep 17 00:00:00 2001 From: yackob03 Date: Tue, 29 Oct 2013 14:42:16 -0400 Subject: [PATCH] Fix the forking problem in the buildserver. --- buildserver/buildserver.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/buildserver/buildserver.py b/buildserver/buildserver.py index 8ee7f4089..82cb24ac7 100644 --- a/buildserver/buildserver.py +++ b/buildserver/buildserver.py @@ -146,7 +146,15 @@ build = { pool = ThreadPool(1) -def start_build(resource_url, tag_name, acccess_token): +@app.before_first_request +def start_build(): + resource_url = os.environ['RESOURCE_URL'] + tag_name = os.environ['TAG'] + acccess_token = os.environ['TOKEN'] + + logger.debug('Starting job with resource url: %s tag: %s and token: %s' % + (resource_url, tag_name, acccess_token)) + # Save the token host = re.match(r'([a-z0-9.:]+)/.+/.+$', tag_name) if host: @@ -201,13 +209,4 @@ def health_check(): if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT) - resource_url = os.environ['RESOURCE_URL'] - tag_name = os.environ['TAG'] - acccess_token = os.environ['TOKEN'] - - logger.debug('Starting job with resource url: %s tag: %s and token: %s' % - (resource_url, tag_name, acccess_token)) - - start_build(resource_url, tag_name, acccess_token) - app.run(host='0.0.0.0', port=5002)