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 ...@@ -25,9 +25,12 @@ Features of the agent
""" """
from __future__ import absolute_import from __future__ import absolute_import
import sys
import logging import logging
import click import click
from multiprocessing import active_children
from .connectors import TunConnector from .connectors import TunConnector
from .connectors import CoreConnector from .connectors import CoreConnector
from .connectors import SerialConnector from .connectors import SerialConnector
...@@ -295,15 +298,34 @@ For more information: README.md ...@@ -295,15 +298,34 @@ For more information: README.md
data['re_route_packets_if'] = re_route_packets_if data['re_route_packets_if'] = re_route_packets_if
self.plugins["tun"] = TunConnector(**data) self.plugins["tun"] = TunConnector(**data)
# start all processes
for p in self.plugins.values(): for p in self.plugins.values():
p.start() p.start()
# TODO re-implement with kombu and BaseController/CoreConsumer log.info('Agent started, processes running: %s'%self.plugins.values())
# TODO fix pcap_dumper support for py2, python3 -m utils.packet_dumper works fine tho
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)
# if dump: # TODO re-implement with kombu and BaseController/CoreConsumer
# dump_p = multiprocessing.Process(target=packet_dumper.launch_amqp_data_to_pcap_dumper, args=()) # TODO fix pcap_dumper support for py2, python3 -m utils.packet_dumper works fine tho
# dump_p.start() # if dump:
# dump_p = multiprocessing.Process(target=packet_dumper.launch_amqp_data_to_pcap_dumper, args=())
# dump_p.start()
def run(self): def run(self):
self.cli() self.cli()
......
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