Ejemplo n.º 1
0
def daemon(action):
    """
    Trigger the daemon, run the action command and return the daemon object
    if required.

    'action' is a string, either start, stop or status
    Returns an instance of deiman.Deiman
    """
    d = Deiman(options.pid)
    if action == "stop":
        d.stop()
        sys.exit(0)
    elif action == "status":
        d.status()
        sys.exit(0)
    if len(sys.argv) == 1:
        print_help()
        sys.exit(2)
    if action == "start":
        d.start()
        return d
    else:
        sys.exit(0)