def cuckoo_main(max_analysis_count=0): """Cuckoo main loop. @param max_analysis_count: kill cuckoo after this number of analyses """ rs, sched = None, None def stop(): if sched: sched.running = False if rs: rs.instance.stop() Pidfile("cuckoo").remove() if sched: sched.stop() def handle_sigterm(sig, f): stop() # Handle a SIGTERM, to reduce the chance of Cuckoo exiting without # cleaning signal.signal(signal.SIGTERM, handle_sigterm) try: rs = ResultServer() sched = Scheduler(max_analysis_count) sched.start() except KeyboardInterrupt: log.info("CTRL+C detected! Stopping.. This can take a few seconds") finally: if Pidfile("cuckoo").exists(): stop()
def cuckoo_main(max_analysis_count=0): """Cuckoo main loop. @param max_analysis_count: kill cuckoo after this number of analyses """ try: ResultServer() sched = Scheduler(max_analysis_count) sched.start() except KeyboardInterrupt: sched.stop()