from portal.log import get_logger from tornado.ioloop import IOLoop from tornado.tcpserver import TCPServer from portal.input.syslog import Parser, SyslogMessageHandler _LOG = get_logger(__name__) class TornadoConnection(object): def __init__(self, reader, stream, address): self.reader = reader self.stream = stream self.address = address # Set our callbacks self.stream.set_close_callback(self._on_close) self.stream.read_until_close( callback=self._on_stream, streaming_callback=self._on_stream) def _on_stream(self, data): try: self.reader.read(data) except Exception as ex: _LOG.exception(ex) def _on_close(self):
from portal.log import get_logger, get_log_manager from portal.server import SyslogServer, start_io, stop_io from portal.output.zmq_out import SyslogToZeroMQHandler, ZeroMQCaster def stop(signum, frame): _LOG.debug('Stop called at frame:\n{}'.format(frame)) stop_io() config = config.load_config() logging_manager = get_log_manager() logging_manager.configure(config) _LOG = get_logger(__name__) if __name__ == '__main__': # Set up the zmq message caster caster = ZeroMQCaster(config.core.zmq_bind_host) ssl_options = None cert_file = config.ssl.cert_file key_file = config.ssl.key_file if None not in (cert_file, key_file): ssl_options = dict() ssl_options['certfile'] = cert_file ssl_options['keyfile'] = key_file