mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-22 16:11:56 +00:00
Create handler for deploying in the IDE
This commit is contained in:
parent
0f379891e3
commit
c5afdfb1b2
@ -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
|
||||
|
29
tfw/components/ide/deploy_handler.py
Normal file
29
tfw/components/ide/deploy_handler.py
Normal 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'
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user