예제 #1
0
def continuous_cap_main_daemon(interval=DEFAULT_INTERVAL):
    pidfile = DAEMON_PIDFILE

    if 'stop' in sys.argv and pidfile.isfile():
        pid = int(pidfile.bytes())
        os.kill(pid, 9)
        pidfile.remove()
        print("killed daemon with pid=%d" % pid)
        return 0

    daemonize(stdout=LOG, stderr=LOG, pidfile=DAEMON_PIDFILE)
    LOG.write_bytes('\ndaemon started at %s\n' % NOW.now(), append=True)

    while True:
        try:
            cap_main()
            LOG.write_bytes('.', append=True)
            time.sleep(interval)
        except KeyboardInterrupt:
            LOG.write_bytes('^C!!!\n', append=True)
            break

    return 0
예제 #2
0
 def _daemonize(self):
     daemonize(stdout=self.stdout, stderr=self.stderr,
               pidfile=self.pidfile)