Update SupervisorMixin users to support stateless API

This commit is contained in:
Kristóf Tóth 2018-02-27 15:54:31 +01:00
parent 789db7416d
commit a6bbe6df55
2 changed files with 7 additions and 5 deletions

View File

@ -12,8 +12,8 @@ class ProcessManager(SupervisorMixin):
'stop': self.stop_process,
'restart': self.restart_process}
def __call__(self, command):
self.commands[command]()
def __call__(self, command, process_name):
self.commands[command](process_name)
class ProcessManagingEventHandler(TriggerlessEventHandler):
@ -24,5 +24,7 @@ class ProcessManagingEventHandler(TriggerlessEventHandler):
self.uplink = ServerUplinkConnector()
def handle_event(self, key, data_json):
self.processmanager(data_json['data']['command'])
self.uplink.send(self.key, {'key': self.key})
data = data_json['data']
self.processmanager(data['command'], data['process_name'])
self.uplink.send(self.key, {'key': self.key,
'data': {'process_name': data['process_name']}})

View File

@ -10,7 +10,7 @@ class TerminadoEventHandler(TriggerlessEventHandler, SupervisorMixin):
super().__init__(key)
self.working_directory = tfwenv.TERMINADO_DIR
self.process_name = process_name
self.start_process()
self.start_process(self.process_name)
def handle_event(self, key, data_json):
log.debug('TerminadoEventHandler received event for key {}'.format(key))