def main(): daemon = MyDaemon('/tmp/daemon-example.pid') 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)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM); s.bind(('127.0.0.1', 10102)); s.listen(1); while 1: conn, addr = s.accept(); while 1: data = conn.recv(8); if not data: break if data != b"8atod3pa": break else: a = threading.Thread(None, playsound); a.start(); conn.close(); if __name__ == "__main__": daemon = MyDaemon('/tmp/playsound.pid') 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)
run(opts) daemon.Daemon.run = run_patch # Perform service action daemon = daemon.Daemon('telemetry', opts['fgdaemon'], '/var/run/aerospike/telemetry.pid', opts['user'], opts['group']) if 'start' == service_action: daemon.start() elif 'stop' == service_action: daemon.stop() elif 'status' == service_action: daemon.status() elif 'restart' == service_action: daemon.restart() elif 'try-restart' == service_action: daemon.try_restart() else: sys.stderr.write(usage_nl) sys.stderr.write("\nUnknown service action [%s]\n" % service_action) sys.exit(2) sys.exit(0) else: sys.stderr.write(usage_nl) sys.stderr.write( "\nIncorrect number of arguments [%d] : %s -- Must supply a single service action for daemon mode.\n" % (len(args), args)) sys.exit(2)