Esempio n. 1
0
    def start(self, **kwargs):
        drop_privileges(self.conf.get('user', 'openio'))
        redirect_stdio(self.logger)

        def kill_children():
            os.killpg(0, signal.SIGTERM)
            self.stop()
            sys.exit()

        def _on_SIGTERM(*args):
            signal.signal(signal.SIGTERM, signal.SIG_IGN)
            kill_children()

        def _on_SIGQUIT(*args):
            signal.signal(signal.SIGQUIT, signal.SIG_IGN)
            kill_children()

        def _on_SIGINT(*args):
            signal.signal(signal.SIGINT, signal.SIG_IGN)
            kill_children()

        signal.signal(signal.SIGINT, _on_SIGINT)
        signal.signal(signal.SIGQUIT, _on_SIGQUIT)
        signal.signal(signal.SIGTERM, _on_SIGTERM)

        self.run(**kwargs)
Esempio n. 2
0
 def __init__(self, conf_file, worker_class, **kwargs):
     section_name = 'event-agent'
     self.conf = read_conf(conf_file, section_name)
     self.logger = get_logger(self.conf,
                              verbose=kwargs.pop('verbose', False))
     redirect_stdio(self.logger)
     drop_privileges(self.conf.get('user', 'openio'))
     self.num_workers = int_value(self.conf.get('workers'), CPU_COUNT)
     self.worker_class = worker_class
     self.workers = {}
     self.sig_queue = []
Esempio n. 3
0
# Copyright (C) 2019 OpenIO SAS, as part of OpenIO SDS
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys
from tempfile import NamedTemporaryFile
from oio.common.logger import get_logger, redirect_stdio

with NamedTemporaryFile(mode='rb', prefix='nolog-') as tmp:
    LOGGER = get_logger({'log_address': tmp.name})
    redirect_stdio(LOGGER)
    LOGGER.warn('Trying to log something boring.')

sys.exit(0)