예제 #1
0
    class DiamondThread(threading.Thread):
        def __init__(self, config):
            threading.Thread.__init__(self)
            self.server = Server(config)

        def run(self):
            self.server.run()

        def stop(self):
            self.server.stop()
            self.server.scheduler.stop()
예제 #2
0
    class DiamondThread(threading.Thread):

        def __init__(self, config):
            threading.Thread.__init__(self)
            self.server = Server(config)

        def run(self):
            self.server.run()

        def stop(self):
            self.server.stop()
            self.server.scheduler.stop()
예제 #3
0
파일: main.py 프로젝트: sara62/Diamond
            # Log
            log.debug("Signal Received: %d" % (signum))
            # Stop Server
            server.stop()
            # Delete Pidfile
            if not options.skip_pidfile and os.path.exists(options.pidfile):
                os.remove(options.pidfile)
                # Log
                log.debug("Removed PID file: %s" % (options.pidfile))

        # Set the signal handlers
        signal.signal(signal.SIGINT, sigint_handler)
        signal.signal(signal.SIGTERM, sigint_handler)

        if options.collector:
            # Run Server with one collector
            server.run_one(options.collector)
        else:
            # Run Server
            server.run()

    # Pass the exit up stream rather then handle it as an general exception
    except SystemExit, e:
        raise SystemExit

    except Exception, e:
        import traceback
        log.error("Unhandled exception: %s" % str(e))
        log.error("traceback: %s" % traceback.format_exc())
        sys.exit(1)
예제 #4
0
        def sigint_handler(signum, frame):
            log.info("Signal Received: %d" % (signum))
            # Delete Pidfile
            if not options.skip_pidfile and os.path.exists(options.pidfile):
                os.remove(options.pidfile)
                # Log
                log.debug("Removed PID file: %s" % (options.pidfile))
            for child in multiprocessing.active_children():
                child.terminate()
            sys.exit(0)

        # Set the signal handlers
        signal.signal(signal.SIGINT, sigint_handler)
        signal.signal(signal.SIGTERM, sigint_handler)

        server.run()

    # Pass the exit up stream rather then handle it as an general exception
    except SystemExit, e:
        raise SystemExit

    except Exception, e:
        import traceback
        log.error("Unhandled exception: %s" % str(e))
        log.error("traceback: %s" % traceback.format_exc())
        sys.exit(1)


if __name__ == "__main__":
    if setproctitle:
        setproctitle(os.path.basename(__file__))