if pid: msg = "Running as PID %d" % pid print msg sys.exit(0) else: msg = "Not running" print msg sys.exit(1) if (sys.argv[1] == 'start'): if pid: print "Running as PID %d" % pid sys.exit(1) signal.signal(signal.SIGUSR1, instance.stop) burrdaemon.run(instance.run, dir='/tmp', ident='tbd', pidFilePath=instance.pidfile_path) sys.exit(0) if (sys.argv[1] == 'stop'): if not pid: print "Not running" sys.exit(1) try: os.kill(pid, signal.SIGUSR1) #os.kill(pid, signal.SIGTERM) sys.exit(0) except OSError, exc: print "Failed to terminate %(pid)d: %(exc)s" % vars() sys.exit(1) print "Unknown command '%s'" % sys.argv[1]
if wait_started + wait_for_done < now: if not silent: msg = "Grew tired of waiting" print msg syslog.syslog(msg) break time.sleep(0.1) if pid: if not silent: msg = "Running as PID %d" % pid print msg syslog.syslog(msg) sys.exit(1) signal.signal(signal.SIGUSR1, instance.stop) burrdaemon.run(instance.run, dir=os.path.dirname(instance.pidfile_path), ident='timelapse_service', pidFilePath=instance.pidfile_path) sys.exit(0) def stop_cleanup(): try: os.unlink(instance.pidfile_path+'.stopping') except OSError as e: print >>sys.stderr, "cleanup failed:", e return False wait_for_exit = datetime.timedelta(seconds=10) if (sys.argv[1] == 'stop'): if not pid: if not silent: msg = "Not running"
if pid: msg = "Running as PID %d" % pid print msg sys.exit(0) else: msg = "Not running" print msg sys.exit(1) if (sys.argv[1] == 'start'): if pid: print "Running as PID %d" % pid sys.exit(1) signal.signal(signal.SIGUSR1, instance.stop) burrdaemon.run(instance.run, dir='/tmp', ident='tbd', pidFilePath=instance.pidfile_path) sys.exit(0) if (sys.argv[1] == 'stop'): if not pid: print "Not running" sys.exit(1) try: os.kill(pid, signal.SIGUSR1) #os.kill(pid, signal.SIGTERM) sys.exit(0) except OSError, exc: print "Failed to terminate %(pid)d: %(exc)s" % vars() sys.exit(1)
if not silent: msg = "Grew tired of waiting" print msg syslog.syslog(msg) break time.sleep(0.1) if pid: if not silent: msg = "Running as PID %d" % pid print msg syslog.syslog(msg) sys.exit(1) signal.signal(signal.SIGUSR1, instance.stop) burrdaemon.run(instance.run, dir=os.path.dirname(instance.pidfile_path), ident='timelapse_service', pidFilePath=instance.pidfile_path) sys.exit(0) def stop_cleanup(): try: os.unlink(instance.pidfile_path + '.stopping') except OSError as e: print >> sys.stderr, "cleanup failed:", e return False wait_for_exit = datetime.timedelta(seconds=10) if (sys.argv[1] == 'stop'): if not pid: if not silent: msg = "Not running"