Exemplo n.º 1
0
def main():
    if len(sys.argv) == 2:
        daemon = work_daemon(pidfile)
        if "start" == sys.argv[1]:
            work_log.info("------admin start daemon run ")
            daemon.start()
        elif "stop" == sys.argv[1]:
            work_log.info("------admin stop")
            daemon.stop()
        elif "restart" == sys.argv[1]:
            work_log.info("------admin restart")
            daemon.restart()
        else:
            print("unkonow command")
            sys.exit(2)
        sys.exit(0)
    elif len(sys.argv) == 1:
        work_start()
Exemplo n.º 2
0
def main():
    if len(sys.argv) == 2:
        daemon=work_daemon(pidfile)
        if 'start' == sys.argv[1]:
            work_log.info('------admin start daemon run ')
            daemon.start()
        elif 'stop' == sys.argv[1]:
            work_log.info('------admin stop')
            daemon.stop()
        elif 'restart' == sys.argv[1]:
            work_log.info('------admin restart')
            daemon.restart()
        else:
            print('unkonow command')
            sys.exit(2)
        sys.exit(0)
    elif len(sys.argv) == 1:
        work_start()
Exemplo n.º 3
0
class BantamDaemon(daemon.Daemon):
    def __init__(self, pidfile='/tmp/bantam.pid'):
        super(BantamDaemon, self).__init__(pidfile)
        DIR = os.path.dirname(os.path.realpath(__file__))
        self.conf = yaml.safe_load(open("{}/config/bantam.cfg".format(DIR)))
        self.conf['base_path'] = DIR

    def run(self):
        engine = bantam.Bantam(self.conf)
        app = engine.build()
        app.serve()

if __name__ == "__main__":
    daemon = BantamDaemon()

    if len(sys.argv) == 2:
        if 'start' == sys.argv[1]:
            daemon.start()
        elif 'stop' == sys.argv[1]:
            daemon.stop()
        elif 'restart' == sys.argv[1]:
            daemon.restart()
        else:
            print("Unknown command")
            sys.exit(2)
        sys.exit(0)
    else:
        print("usage: %s start|stop|restart" % sys.argv[0])
        sys.exit(2)