This repository has been archived by the owner on Oct 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
deliver
executable file
·77 lines (60 loc) · 1.86 KB
/
deliver
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python
import os
import sys
import argparse
from VEDA.utils import get_config
project_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if project_path not in sys.path:
sys.path.append(project_path)
class DeliverCli(object):
"""
Deliver
Command Line Interface
"""
def __init__(self, **kwargs):
self.args = None
self.test = False
self.logging = kwargs.get('logging', True)
self.ROOT_DIR = os.path.dirname(os.path.dirname(
os.path.abspath(__file__)
))
self.celery_daemon = os.path.join(self.ROOT_DIR, 'control', 'celeryapp.py')
def get_args(self):
parser = argparse.ArgumentParser()
parser.usage = '''
{cmd} -l List
[-l ]
Use --help to see all options.
'''.format(cmd=sys.argv[0])
parser.add_argument(
'-l', '--list',
help='Unused, Exit',
action='store_true'
)
self.args = parser.parse_args()
self._parse_args()
def _parse_args(self):
self.list = self.args.list
def run(self):
"""
Launch Celery Delivery Worker
"""
auth_dict = get_config()
if auth_dict is not None:
os.system(
' '.join((
'python',
self.celery_daemon,
'worker',
'--loglevel=info',
'--concurrency=' + str(auth_dict['celery_threads']),
'-Q ' + auth_dict['celery_deliver_queue'] + ',' + auth_dict['celery_heal_queue'] + ',' + auth_dict['celery_online_heal_queue'],
'-n deliver.%h'
))
)
def main():
deliverinstance = DeliverCli()
deliverinstance.get_args()
deliverinstance.run()
if __name__ == '__main__':
sys.exit(main())