1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#!/usr/bin/env python
# -*- mode: python -*-
#
# This file is part of eventmq.
#
# eventmq is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# eventmq is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with eventmq. If not, see <http://www.gnu.org/licenses/>.
import argparse
from eventmq.jobmanager import JobManager
from eventmq import conf
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Listen for job requests and '
'manage their execution')
parser.add_argument('--broker-addr', '-B', type=str, nargs='?',
help='manually specify the broker address to connect '
'to in order to receive jobs')
parser.add_argument('--config', '-C', type=str, nargs='?',
help='manually specify the location of eventmq.conf')
parser.add_argument('--queues', '-Q', type=str, nargs='+',
help='space separated list of queue names to listen '
'on')
parser.add_argument('--jobs', '-J', type=int, nargs='?',
help='the max number of concurrent jobs to manage at '
'a time')
parser.add_argument('--name', '-n', type=str, default=None,
help="A unique ame to give this node. If one "
"isn't provided a random uuid will be "
"generated")
args = parser.parse_args()
# Overwrite the default config location with the one passed to the app
if args.config:
conf.CONFIG_FILE = args.config
# args.queues is a list of queues or None
queues = args.queues
if queues:
queues = ','.join(queues)
broker_addr = args.broker_addr
concurrent_jobs = args.jobs
name = args.name
j = JobManager(queues=queues, concurrent_jobs=concurrent_jobs,
name=name)
j.jobmanager_main(broker_addr=broker_addr)
|