history, as of 2022-02-01
Change-Id: I725a57546df8f7c9e5ffe04eb98872f2a609efe4
This commit is contained in:
@ -114,6 +114,7 @@ class Server:
|
||||
self.log.warning('ambiguous sections in %s: %r' % (cfgfiles, tuple(ambiguous_sections)))
|
||||
self._cfgfiles = cfgfiles
|
||||
self._pidfile = os.path.join(cfg['piddir'], name + '.pid')
|
||||
self.close_callbacks = []
|
||||
|
||||
def loadCfgFile(self, cfgfile):
|
||||
if not cfgfile.endswith('.cfg'):
|
||||
@ -210,8 +211,7 @@ class Server:
|
||||
self.interface.serve_forever()
|
||||
except KeyboardInterrupt as e:
|
||||
self._restart = False
|
||||
self.dispatcher.close()
|
||||
self.interface.server_close()
|
||||
self.close()
|
||||
if self._restart:
|
||||
self.restart_hook()
|
||||
self.log.info('restart')
|
||||
@ -227,6 +227,12 @@ class Server:
|
||||
self._restart = False
|
||||
self.interface.shutdown()
|
||||
|
||||
def close(self):
|
||||
self.dispatcher.close()
|
||||
self.interface.server_close()
|
||||
for cb in self.close_callbacks:
|
||||
cb()
|
||||
|
||||
def _processCfg(self):
|
||||
errors = []
|
||||
opts = dict(self.node_cfg)
|
||||
@ -338,8 +344,13 @@ class Server:
|
||||
self.log.info('all modules and pollers started')
|
||||
history_path = os.environ.get('FRAPPY_HISTORY')
|
||||
if history_path:
|
||||
from secop_psi.historywriter import add_writer # pylint: disable=import-outside-toplevel
|
||||
add_writer(history_path, self)
|
||||
try:
|
||||
from secop.historywriter import FrappyHistory # pylint: disable=import-outside-toplevel
|
||||
history = FrappyHistory(history_path, self.modules, self.log.getChild('history'))
|
||||
self.close_callbacks.append(history.close)
|
||||
except ImportError:
|
||||
raise
|
||||
self.log.warning('FRAPPY_HISTORY is defined, but frappyhistory package not available')
|
||||
# TODO: if ever somebody wants to implement an other history writer:
|
||||
# - a general config file /etc/secp/secop.conf or <frappy repo>/etc/secop.conf
|
||||
# might be introduced, which contains the log, pid and cfg directory path and
|
||||
|
Reference in New Issue
Block a user