Пример #1
0
def main():
    import argparse
    import os
    import signal
    import sys

    from gonium.service_aggregation import ServiceAggregate

    p = argparse.ArgumentParser()
    p.add_argument('--config', '-c', default='~/.taf/config')
    p.add_argument('--loglevel', '-L', default=20, type=int)

    args = p.parse_args()
    logging.basicConfig(format='%(asctime)s %(levelno)s %(message)s',
                        stream=sys.stderr,
                        level=args.loglevel)

    sa = ServiceAggregate()

    sa.bump_ml = lambda: os.write(sa.sc._pipe_w, b'\x00')

    config_fn = os.path.expanduser(args.config)
    config = Config(sa)
    config.load_config_by_fn(config_fn)

    config.file_pid()

    n = Notifier(config)
    n.start_forward(*config.forward_args)

    # Signal handling
    def handle_signals(si_l):
        for si in si_l:
            if (si.signo in (signal.SIGTERM, signal.SIGINT)):
                sa.ed.shutdown()
                log(50, 'Shutting down on signal {}.'.format(si.signo))
                break
            if (si.signo == signal.SIGUSR1):
                n.reset()
                break

    sa.sc.handle_signals.new_listener(handle_signals)
    for sig in (signal.SIGTERM, signal.SIGINT, signal.SIGUSR1):
        sa.sc.sighandler_install(sig, sa.sc.SA_RESTART)

    config.run_inits()
    log(20, 'Starting operation.')
    sa.ed.event_loop()
    config.run_finis()
    log(20, 'Terminating.')
Пример #2
0
Файл: taf_ui.py Проект: sh01/taf
def main():
  import argparse
  import os
  import signal
  import sys

  from gonium.service_aggregation import ServiceAggregate

  p = argparse.ArgumentParser()
  p.add_argument('--config', '-c', default='~/.taf/config')
  p.add_argument('--loglevel', '-L', default=20, type=int)

  args = p.parse_args()
  logging.basicConfig(format='%(asctime)s %(levelno)s %(message)s', stream=sys.stderr, level=args.loglevel)

  sa = ServiceAggregate()

  sa.bump_ml = lambda: os.write(sa.sc._pipe_w, b'\x00')

  config_fn = os.path.expanduser(args.config)
  config = Config(sa)
  config.load_config_by_fn(config_fn)

  config.file_pid()

  n = Notifier(config)
  n.start_forward(*config.forward_args)

  # Signal handling
  def handle_signals(si_l):
    for si in si_l:
      if (si.signo in (signal.SIGTERM, signal.SIGINT)):
        sa.ed.shutdown()
        log(50, 'Shutting down on signal {}.'.format(si.signo))
        break
      if (si.signo == signal.SIGUSR1):
        n.reset()
        break

  sa.sc.handle_signals.new_listener(handle_signals)
  for sig in (signal.SIGTERM, signal.SIGINT, signal.SIGUSR1):
    sa.sc.sighandler_install(sig, sa.sc.SA_RESTART)

  config.run_inits()
  log(20, 'Starting operation.')
  sa.ed.event_loop()
  config.run_finis()
  log(20, 'Terminating.')
Пример #3
0
 def get_proto_config(self):
     from taf.event_proto import Config
     c = Config()
     c.auto_reset = self.auto_reset
     return c
Пример #4
0
Файл: taf_ui.py Проект: sh01/taf
 def get_proto_config(self):
   from taf.event_proto import Config
   c = Config()
   c.auto_reset = self.auto_reset
   return c