Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9481e8f921 | ||
|
|
c8d4080ef5 | ||
|
|
269cab691e | ||
|
|
16f0335d76 | ||
|
|
52280acf41 | ||
|
|
1b274fa019 | ||
|
|
ba4803d660 | ||
|
|
ac198e5731 |
+6
-2
@@ -1,5 +1,9 @@
|
|||||||
FROM avatao/frontend-tutorial-framework:chausie-20191021 as frontend
|
ARG FRONTEND_VERSION
|
||||||
|
FROM avatao/frontend-tutorial-framework:${FRONTEND_VERSION} as frontend
|
||||||
|
|
||||||
FROM avatao/debian:buster
|
FROM avatao/debian:buster
|
||||||
|
ARG FRONTEND_VERSION
|
||||||
|
LABEL tfw.frontend.version=${FRONTEND_VERSION}
|
||||||
|
|
||||||
RUN apt-get update &&\
|
RUN apt-get update &&\
|
||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
@@ -69,7 +73,7 @@ ONBUILD COPY ${BUILD_CONTEXT}/supervisor/ ${TFW_SUPERVISORD_COMPONENTS}
|
|||||||
ONBUILD RUN for f in "${TFW_NGINX_DEFAULT}" ${TFW_NGINX_COMPONENTS}/*.conf; do \
|
ONBUILD RUN for f in "${TFW_NGINX_DEFAULT}" ${TFW_NGINX_COMPONENTS}/*.conf; do \
|
||||||
envsubst "$(printenv | cut -d= -f1 | grep TFW_ | sed -e 's/^/$/g')" < $f > $f~ && mv $f~ $f ;\
|
envsubst "$(printenv | cut -d= -f1 | grep TFW_ | sed -e 's/^/$/g')" < $f > $f~ && mv $f~ $f ;\
|
||||||
done
|
done
|
||||||
ONBUILD VOLUME ["/etc/nginx", "/var/lib/nginx", "/var/log/nginx", "${TFW_LIB_DIR}/tfw"]
|
ONBUILD VOLUME ["/etc/nginx", "/etc/supervisor", "/var/lib/nginx", "/var/log/nginx", "${TFW_LIB_DIR}/tfw"]
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/init", "--"]
|
ENTRYPOINT ["/bin/init", "--"]
|
||||||
CMD exec supervisord --nodaemon --configuration ${TFW_SUPERVISORD_CONF}
|
CMD exec supervisord --nodaemon --configuration ${TFW_SUPERVISORD_CONF}
|
||||||
|
|||||||
@@ -4,3 +4,4 @@ directory=/tmp
|
|||||||
command=bash tfw_init.sh
|
command=bash tfw_init.sh
|
||||||
autorestart=false
|
autorestart=false
|
||||||
startsecs=0
|
startsecs=0
|
||||||
|
priority=1
|
||||||
|
|||||||
@@ -2,3 +2,4 @@
|
|||||||
user=root
|
user=root
|
||||||
directory=%(ENV_TFW_SERVER_DIR)s
|
directory=%(ENV_TFW_SERVER_DIR)s
|
||||||
command=python3 -u tfw_server.py
|
command=python3 -u tfw_server.py
|
||||||
|
priority=2
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class FrontendConfigHandler:
|
|||||||
def handle_event(self, _, connector):
|
def handle_event(self, _, connector):
|
||||||
# pylint: disable=no-self-use
|
# pylint: disable=no-self-use
|
||||||
for message in self._config_messages:
|
for message in self._config_messages:
|
||||||
connector.send_message(message)
|
connector.send_message(message, scope=Scope.WEBSOCKET)
|
||||||
connector.send_message({'key': 'frontend.ready'}, scope=Scope.WEBSOCKET)
|
connector.send_message({'key': 'frontend.ready'}, scope=Scope.WEBSOCKET)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -16,10 +16,13 @@ class ProcessLogHandler:
|
|||||||
self._initial_log_tail = log_tail
|
self._initial_log_tail = log_tail
|
||||||
|
|
||||||
self.command_handlers = {
|
self.command_handlers = {
|
||||||
'process.log.set': self.handle_set
|
'process.log.set': self.handle_set,
|
||||||
|
'process.log.start': self.handle_start,
|
||||||
|
'process.log.stop': self.handle_stop
|
||||||
}
|
}
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
if not self._monitor:
|
||||||
self._monitor = LogInotifyObserver(
|
self._monitor = LogInotifyObserver(
|
||||||
connector=self.connector,
|
connector=self.connector,
|
||||||
process_name=self.process_name,
|
process_name=self.process_name,
|
||||||
@@ -40,5 +43,16 @@ class ProcessLogHandler:
|
|||||||
if data.get('tail'):
|
if data.get('tail'):
|
||||||
self._monitor.log_tail = data['tail']
|
self._monitor.log_tail = data['tail']
|
||||||
|
|
||||||
def cleanup(self):
|
def handle_start(self, _):
|
||||||
|
self.start()
|
||||||
|
|
||||||
|
def handle_stop(self, _):
|
||||||
|
self._stop_monitor()
|
||||||
|
|
||||||
|
def _stop_monitor(self):
|
||||||
|
if self._monitor:
|
||||||
self._monitor.stop()
|
self._monitor.stop()
|
||||||
|
self._monitor = None
|
||||||
|
|
||||||
|
def cleanup(self):
|
||||||
|
self._stop_monitor()
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ class TerminalHandler:
|
|||||||
LOG.error('IGNORING MESSAGE: Invalid message received: %s', message)
|
LOG.error('IGNORING MESSAGE: Invalid message received: %s', message)
|
||||||
|
|
||||||
def handle_write(self, message):
|
def handle_write(self, message):
|
||||||
|
concat = message.get('concat', False)
|
||||||
|
if not concat:
|
||||||
|
self.terminado_server.pty.write('\x15')
|
||||||
self.terminado_server.pty.write(message['command'])
|
self.terminado_server.pty.write(message['command'])
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
|
|||||||
+3
-4
@@ -1,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from contextlib import suppress
|
||||||
|
|
||||||
from transitions import Machine, MachineError
|
from transitions import Machine, MachineError
|
||||||
|
|
||||||
@@ -62,14 +63,12 @@ class FSMBase(Machine, CallbackMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if all(predicate_results):
|
if all(predicate_results):
|
||||||
try:
|
with suppress(AttributeError, MachineError):
|
||||||
from_state = self.state
|
from_state = self.state
|
||||||
self.trigger(trigger)
|
if self.trigger(trigger):
|
||||||
self.update_event_log(from_state, trigger)
|
self.update_event_log(from_state, trigger)
|
||||||
return True
|
return True
|
||||||
except (AttributeError, MachineError):
|
|
||||||
LOG.debug('FSM failed to execute nonexistent trigger: "%s"', trigger)
|
LOG.debug('FSM failed to execute nonexistent trigger: "%s"', trigger)
|
||||||
return False
|
|
||||||
|
|
||||||
def update_event_log(self, from_state, trigger):
|
def update_event_log(self, from_state, trigger):
|
||||||
self.event_log.append({
|
self.event_log.append({
|
||||||
|
|||||||
+2
-1
@@ -2,6 +2,7 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import TextIO, Union
|
from typing import TextIO, Union
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
from collections.abc import Mapping
|
||||||
from traceback import format_exception
|
from traceback import format_exception
|
||||||
from logging import DEBUG, getLogger, Handler, Formatter, Filter
|
from logging import DEBUG, getLogger, Handler, Formatter, Filter
|
||||||
|
|
||||||
@@ -81,7 +82,7 @@ class LogFormatter(Formatter):
|
|||||||
def format(self, record):
|
def format(self, record):
|
||||||
time = datetime.utcfromtimestamp(record.created).strftime('%H:%M:%S')
|
time = datetime.utcfromtimestamp(record.created).strftime('%H:%M:%S')
|
||||||
if record.args:
|
if record.args:
|
||||||
tuple_args = (record.args,) if isinstance(record.args, dict) else record.args
|
tuple_args = (record.args,) if isinstance(record.args, Mapping) else record.args
|
||||||
clean_args = tuple((self.trim(arg) for arg in tuple_args))
|
clean_args = tuple((self.trim(arg) for arg in tuple_args))
|
||||||
message = record.msg % clean_args
|
message = record.msg % clean_args
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user