|
Neal Gompa |
55fa35 |
#!/usr/bin/env python
|
|
Pierre-Yves Chibon |
6c9788 |
|
|
Aurélien Bompard |
dcf6f6 |
from __future__ import unicode_literals
|
|
Aurélien Bompard |
dcf6f6 |
|
|
Pierre-Yves Chibon |
6c9788 |
# These two lines are needed to run on EL6
|
|
Pierre-Yves Chibon |
6c9788 |
__requires__ = ['SQLAlchemy >= 0.8', 'jinja2 >= 2.4']
|
|
Pierre-Yves Chibon |
6c9788 |
import pkg_resources
|
|
Pierre-Yves Chibon |
6c9788 |
|
|
Pierre-Yves Chibon |
6c9788 |
import argparse
|
|
Pierre-Yves Chibon |
6c9788 |
import sys
|
|
Pierre-Yves Chibon |
6c9788 |
import os
|
|
Pierre-Yves Chibon |
6c9788 |
import subprocess
|
|
Pierre-Yves Chibon |
6c9788 |
|
|
Pierre-Yves Chibon |
6c9788 |
|
|
Pierre-Yves Chibon |
6c9788 |
parser = argparse.ArgumentParser(
|
|
Pierre-Yves Chibon |
6c9788 |
description='Run the Pagure worker')
|
|
Pierre-Yves Chibon |
6c9788 |
parser.add_argument(
|
|
Pierre-Yves Chibon |
6c9788 |
'--config', '-c', dest='config',
|
|
Pierre-Yves Chibon |
6c9788 |
help='Configuration file to use for pagure.')
|
|
Pierre-Yves Chibon |
6c9788 |
parser.add_argument(
|
|
Pierre-Yves Chibon |
6c9788 |
'--debug', dest='debug', action='store_true',
|
|
Pierre-Yves Chibon |
6c9788 |
default=False,
|
|
Pierre-Yves Chibon |
6c9788 |
help='Expand the level of data returned.')
|
|
Pierre-Yves Chibon |
6c9788 |
parser.add_argument(
|
|
Pierre-Yves Chibon |
6c9788 |
'--noinfo', dest='noinfo', action='store_true',
|
|
Pierre-Yves Chibon |
6c9788 |
default=False,
|
|
Pierre-Yves Chibon |
6c9788 |
help='Reduce the log level.')
|
|
Pierre-Yves Chibon |
6c9788 |
|
|
Pierre-Yves Chibon |
6c9788 |
args = parser.parse_args()
|
|
Pierre-Yves Chibon |
6c9788 |
|
|
Pierre-Yves Chibon |
6c9788 |
env = {}
|
|
Pierre-Yves Chibon |
6c9788 |
if args.config:
|
|
Pierre-Yves Chibon |
6c9788 |
config = args.config
|
|
Pierre-Yves Chibon |
6c9788 |
if not config.startswith('/'):
|
|
Pierre-Yves Chibon |
6c9788 |
here = os.path.join(os.path.dirname(os.path.abspath(__file__)))
|
|
Pierre-Yves Chibon |
6c9788 |
config = os.path.join(here, config)
|
|
Pierre-Yves Chibon |
6c9788 |
env['PAGURE_CONFIG'] = config
|
|
Pierre-Yves Chibon |
6c9788 |
|
|
Pierre-Yves Chibon |
6c9788 |
cmd = [
|
|
Pierre-Yves Chibon |
fc887f |
sys.executable, '-m', 'celery', 'worker', '-A', 'pagure.lib.tasks'
|
|
Pierre-Yves Chibon |
6c9788 |
]
|
|
Pierre-Yves Chibon |
6c9788 |
|
|
Pierre-Yves Chibon |
6c9788 |
if args.debug:
|
|
Pierre-Yves Chibon |
6c9788 |
cmd.append('--loglevel=debug')
|
|
Pierre-Yves Chibon |
6c9788 |
elif args.noinfo:
|
|
Pierre-Yves Chibon |
6c9788 |
pass
|
|
Pierre-Yves Chibon |
6c9788 |
else:
|
|
Pierre-Yves Chibon |
6c9788 |
cmd.append('--loglevel=info')
|
|
Pierre-Yves Chibon |
6c9788 |
|
|
Pierre-Yves Chibon |
ce9edd |
subp = subprocess.Popen(cmd, env=env or None)
|
|
Pierre-Yves Chibon |
ce9edd |
subp.wait()
|