-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmanager.py
39 lines (26 loc) · 896 Bytes
/
manager.py
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
from client.service import Service
from client.watcher import Watcher
import yaml
class Manager(object):
def __init__(self, config):
with open(config, "r") as f:
config = yaml.load(f.read())
self.s = Service(config['key'])
self.watchers = []
for k, v in config['tasks'].items():
self.watchers.append(Watcher(k, v, self.s))
def start_watching(self):
"""Start the watchers"""
print ("Starting watchers. Press Ctrl+C to exit")
for x in self.watchers:
x.start()
def stop_watching(self):
"""Start the watcher and return"""
print ("Stopping the watching services...")
for x in self.watchers:
x.shutdown()
self.s.shutdown()
for x in self.watchers:
x.join()
self.s.join()
print ("Stopped!")