From 6c9788498146ed8185afdaf4e97447c2eb334539 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 01 2017 09:18:54 +0000 Subject: [PATCH 1/6] Add a small runworker utility script to start a worker to work on pagure Signed-off-by: Pierre-Yves Chibon --- diff --git a/runworker.py b/runworker.py new file mode 100755 index 0000000..5aeef4e --- /dev/null +++ b/runworker.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python2 + +# These two lines are needed to run on EL6 +__requires__ = ['SQLAlchemy >= 0.8', 'jinja2 >= 2.4'] +import pkg_resources + +import argparse +import sys +import os +import subprocess + + +parser = argparse.ArgumentParser( + description='Run the Pagure worker') +parser.add_argument( + '--config', '-c', dest='config', + help='Configuration file to use for pagure.') +parser.add_argument( + '--debug', dest='debug', action='store_true', + default=False, + help='Expand the level of data returned.') +parser.add_argument( + '--noinfo', dest='noinfo', action='store_true', + default=False, + help='Reduce the log level.') + +args = parser.parse_args() + +env = {} +if args.config: + config = args.config + if not config.startswith('/'): + here = os.path.join(os.path.dirname(os.path.abspath(__file__))) + config = os.path.join(here, config) + env['PAGURE_CONFIG'] = config + +cmd = [ + '/usr/bin/celery', 'worker', '-A', 'pagure.lib.tasks', '--autoreload' +] + +if args.debug: + cmd.append('--loglevel=debug') +elif args.noinfo: + pass +else: + cmd.append('--loglevel=info') + +subprocess.Popen(cmd, env=env or None) From 89046508cf1eb9065056a35a1263d8cc11b2da57 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 01 2017 09:18:54 +0000 Subject: [PATCH 2/6] Add celery to the list of requirements --- diff --git a/requirements.txt b/requirements.txt index cf880fa..ca55b0d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,7 @@ arrow binaryornot < 0.4.3 bleach blinker +celery chardet < 3.0.0 docutils enum34 From cff60cc548f1a3363cad7b850a32d7ad2a708acd Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 01 2017 09:18:54 +0000 Subject: [PATCH 3/6] Add eventlet to the list of dependencies for the tests --- diff --git a/tests_requirements.txt b/tests_requirements.txt index 7941d88..15cb41c 100644 --- a/tests_requirements.txt +++ b/tests_requirements.txt @@ -1,3 +1,4 @@ +eventlet mock==1.1.2 nose nosexcover From ef25dfd2c0e48b9050721a5d65c14152515fc679 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 01 2017 09:18:54 +0000 Subject: [PATCH 4/6] Document how to run the worker in the README Signed-off-by: Pierre-Yves Chibon --- diff --git a/README.rst b/README.rst index b08aa7f..63f29c6 100644 --- a/README.rst +++ b/README.rst @@ -105,8 +105,11 @@ Manually python createdb.py +* Start a worker, in one terminal:: -* Run it:: + ./runworker.py + +* Run the application, in another terminal:: ./runserver.py From ce9eddb3a54e573b495bff53a62a719cf5f9712c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 01 2017 09:18:54 +0000 Subject: [PATCH 5/6] Adjust the runworker utility script as adviced in the review --- diff --git a/runworker.py b/runworker.py index 5aeef4e..a5c5399 100755 --- a/runworker.py +++ b/runworker.py @@ -35,7 +35,8 @@ if args.config: env['PAGURE_CONFIG'] = config cmd = [ - '/usr/bin/celery', 'worker', '-A', 'pagure.lib.tasks', '--autoreload' + sys.executable, '-m', 'celery', 'worker', '-A', 'pagure.lib.tasks', + '--autoreload' ] if args.debug: @@ -45,4 +46,5 @@ elif args.noinfo: else: cmd.append('--loglevel=info') -subprocess.Popen(cmd, env=env or None) +subp = subprocess.Popen(cmd, env=env or None) +subp.wait() From fc887f97a44892a20269f77285918332b72fe20a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 01 2017 09:18:54 +0000 Subject: [PATCH 6/6] Drop the --autoreload argument It was experimental in celery 3.x and has been entirely removed in 4.x Signed-off-by: Pierre-Yves Chibon --- diff --git a/runworker.py b/runworker.py index a5c5399..6d7277e 100755 --- a/runworker.py +++ b/runworker.py @@ -35,8 +35,7 @@ if args.config: env['PAGURE_CONFIG'] = config cmd = [ - sys.executable, '-m', 'celery', 'worker', '-A', 'pagure.lib.tasks', - '--autoreload' + sys.executable, '-m', 'celery', 'worker', '-A', 'pagure.lib.tasks' ] if args.debug: