Commit 03b20946 authored by Federico Sismondi's avatar Federico Sismondi

added monit on running processes

parent 0804682a
......@@ -25,9 +25,12 @@ Features of the agent
"""
from __future__ import absolute_import
import sys
import logging
import click
from multiprocessing import active_children
from .connectors import TunConnector
from .connectors import CoreConnector
from .connectors import SerialConnector
......@@ -295,12 +298,31 @@ For more information: README.md
data['re_route_packets_if'] = re_route_packets_if
self.plugins["tun"] = TunConnector(**data)
# start all processes
for p in self.plugins.values():
p.start()
log.info('Agent started, processes running: %s'%self.plugins.values())
try:
for p in self.plugins.values():
p.join()
except KeyboardInterrupt as ki:
log.warning('Got user interruption (SIGINT), trying to stop processes... ')
log.warning("Start trying to stop active childen: %s" % active_children())
for p in self.plugins.values():
p.terminate()
log.warning("The following process children coundnt be stopped: %s" % active_children())
sys.exit(1)
# TODO re-implement with kombu and BaseController/CoreConsumer
# TODO fix pcap_dumper support for py2, python3 -m utils.packet_dumper works fine tho
# if dump:
# dump_p = multiprocessing.Process(target=packet_dumper.launch_amqp_data_to_pcap_dumper, args=())
# dump_p.start()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment