2019-06-10 13:35:09 +00:00
|
|
|
import logging
|
2019-06-28 15:36:03 +00:00
|
|
|
from sys import stderr
|
2018-06-29 20:08:05 +00:00
|
|
|
from functools import partial
|
2018-05-26 20:53:02 +00:00
|
|
|
|
2018-03-23 14:27:42 +00:00
|
|
|
from tornado.ioloop import IOLoop
|
|
|
|
|
2018-07-26 12:00:24 +00:00
|
|
|
from tfw.fsm import YamlFSM
|
2019-06-28 13:12:27 +00:00
|
|
|
from tfw.builtins import IdeEventHandler, TerminalEventHandler, FrontendEventHandler
|
2019-06-20 14:06:23 +00:00
|
|
|
from tfw.builtins import LogMonitoringEventHandler, ProcessManagingEventHandler
|
2019-07-05 13:37:54 +00:00
|
|
|
from tfw.builtins import DirectorySnapshottingEventHandler, FSMManagingEventHandler
|
2018-03-25 14:34:31 +00:00
|
|
|
from tfw.config import TFWENV
|
2019-06-28 15:36:03 +00:00
|
|
|
from tfw.logging import Log, Logger, LogFormatter, VerboseLogFormatter
|
2019-07-01 12:54:47 +00:00
|
|
|
from tao.config import TAOENV
|
2018-03-31 22:45:15 +00:00
|
|
|
|
2019-07-05 13:37:54 +00:00
|
|
|
from custom_event_handlers import MessageFSMStepsEventHandler
|
|
|
|
from custom_event_handlers import TerminalCallbackEventHandler, TestCommands
|
2019-07-08 09:42:03 +00:00
|
|
|
from signal_handling import setup_signal_handlers
|
2018-04-11 15:34:44 +00:00
|
|
|
|
2019-07-05 13:37:54 +00:00
|
|
|
LOG = logging.getLogger(__name__)
|
2018-07-20 11:37:22 +00:00
|
|
|
|
|
|
|
|
2018-08-07 15:01:58 +00:00
|
|
|
def main():
|
2019-05-15 15:26:02 +00:00
|
|
|
# pylint: disable=unused-variable
|
2019-06-28 15:36:03 +00:00
|
|
|
Logger([
|
|
|
|
Log(stderr, LogFormatter(20)),
|
|
|
|
Log(TFWENV.LOGFILE, VerboseLogFormatter())
|
|
|
|
]).start()
|
2019-06-18 16:51:05 +00:00
|
|
|
|
2018-07-20 11:37:22 +00:00
|
|
|
# TFW component EventHandlers (builtins, required for their respective functionalities)
|
2018-08-07 15:01:58 +00:00
|
|
|
fsm = FSMManagingEventHandler( # TFW FSM
|
2018-06-29 20:08:05 +00:00
|
|
|
key='fsm',
|
2018-07-27 11:59:14 +00:00
|
|
|
fsm_type=partial(
|
|
|
|
YamlFSM,
|
|
|
|
'test_fsm.yml',
|
|
|
|
{} # jinja2 variables, use empty dict to enable jinja2 parsing without any variables
|
|
|
|
)
|
2018-06-29 20:08:05 +00:00
|
|
|
)
|
2018-05-26 20:53:02 +00:00
|
|
|
ide = IdeEventHandler( # Web IDE backend
|
2018-05-30 13:58:19 +00:00
|
|
|
key='ide',
|
|
|
|
allowed_directories=[TFWENV.IDE_WD, TFWENV.WEBSERVICE_DIR],
|
|
|
|
directory=TFWENV.IDE_WD,
|
2018-06-04 19:48:54 +00:00
|
|
|
exclude=['*.pyc']
|
2018-05-26 20:53:02 +00:00
|
|
|
)
|
2018-05-29 16:00:57 +00:00
|
|
|
terminal = TerminalEventHandler( # Web shell backend
|
2019-06-27 12:38:36 +00:00
|
|
|
key='shell'
|
2018-05-26 20:53:02 +00:00
|
|
|
)
|
2019-06-11 15:27:37 +00:00
|
|
|
commands = TerminalCallbackEventHandler( # Reacts to terminal commands
|
|
|
|
'history.bash',
|
|
|
|
TestCommands(bashrc=f'/home/{TAOENV.USER}/.bashrc').callback
|
|
|
|
)
|
2018-05-29 16:00:57 +00:00
|
|
|
processmanager = ProcessManagingEventHandler( # Handles 'deploy' button clicks
|
2018-05-26 20:53:02 +00:00
|
|
|
key='processmanager',
|
2018-05-29 16:00:57 +00:00
|
|
|
log_tail=2000
|
2018-05-26 20:53:02 +00:00
|
|
|
)
|
2018-05-30 11:15:13 +00:00
|
|
|
logmonitor = LogMonitoringEventHandler( # Sends live logs of webservice process to frontend
|
2018-05-30 13:23:54 +00:00
|
|
|
key='logmonitor',
|
|
|
|
process_name='webservice',
|
2018-05-30 11:15:13 +00:00
|
|
|
log_tail=2000
|
|
|
|
)
|
2018-08-07 15:03:41 +00:00
|
|
|
snapshot = DirectorySnapshottingEventHandler( # Manages filesystem snapshots of directories
|
|
|
|
key='snapshot',
|
|
|
|
directories=[
|
|
|
|
TFWENV.IDE_WD,
|
|
|
|
TFWENV.WEBSERVICE_DIR
|
|
|
|
]
|
|
|
|
)
|
2019-05-26 16:31:16 +00:00
|
|
|
frontend = FrontendEventHandler() # Proxies frontend API calls to frontend
|
2018-05-26 20:53:02 +00:00
|
|
|
|
2018-07-20 11:37:22 +00:00
|
|
|
# Your custom event handlers
|
2018-08-07 15:01:58 +00:00
|
|
|
message_fsm_steps_eh = MessageFSMStepsEventHandler(
|
2018-07-20 11:37:22 +00:00
|
|
|
key='test'
|
|
|
|
)
|
|
|
|
|
2019-07-08 09:42:03 +00:00
|
|
|
setup_signal_handlers()
|
2019-05-02 13:07:13 +00:00
|
|
|
IOLoop.instance().start()
|
2018-08-07 15:01:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|