Create handler for deploying in the IDE

This commit is contained in:
R. Richard 2019-08-23 16:24:47 +02:00 committed by therealkrispet
parent 0f379891e3
commit c5afdfb1b2
3 changed files with 31 additions and 1 deletions

View File

@ -4,7 +4,7 @@ from .message_storage import FrontendMessageStorage
class FrontendProxyHandler: class FrontendProxyHandler:
keys = ['console', 'dashboard', 'frontend.ready', 'message', 'ide.read'] keys = ['console', 'dashboard', 'frontend.ready', 'message', 'ide.read', 'deploy.finish']
def __init__(self): def __init__(self):
self.connector = None self.connector = None

View File

@ -1 +1,2 @@
from .ide_handler import IdeHandler from .ide_handler import IdeHandler
from .deploy_handler import DeployHandler

View File

@ -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'
})