Create handler for deploying in the IDE
This commit is contained in:
parent
62cd513d8c
commit
b141b27b36
|
@ -4,7 +4,7 @@ from .message_storage import FrontendMessageStorage
|
|||
|
||||
|
||||
class FrontendProxyHandler:
|
||||
keys = ['console', 'dashboard', 'frontend.ready', 'message', 'ide.read']
|
||||
keys = ['console', 'dashboard', 'frontend.ready', 'message', 'ide.read', 'deploy.finish']
|
||||
|
||||
def __init__(self):
|
||||
self.connector = None
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from .ide_handler import IdeHandler
|
||||
from .deploy_handler import DeployHandler
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
class DeployHandler:
|
||||
keys = ['deploy.start', 'process.restart']
|
||||
|
||||
def __init__(self, process_name='webservice'):
|
||||
self.process_name = process_name
|
||||
|
||||
self.commands = {
|
||||
'deploy.start': self.handle_deploy,
|
||||
'process.restart': self.handle_process
|
||||
}
|
||||
|
||||
def handle_event(self, message, _):
|
||||
try:
|
||||
self.commands[message['key']](message)
|
||||
except KeyError:
|
||||
LOG.error('IGNORING MESSAGE: Invalid message received: %s', message)
|
||||
|
||||
def handle_deploy(self, message):
|
||||
self.connector.send_message({
|
||||
'key': 'process.restart',
|
||||
'name': self.process_name
|
||||
})
|
||||
|
||||
def handle_process(self, message):
|
||||
self.connector.send_message({
|
||||
'key': 'deploy.finish',
|
||||
'status': 'success' if 'error' not in message else 'error'
|
||||
})
|
||||
|
Loading…
Reference in New Issue