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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
Archivo: ps.py Proyecto: dbeecham/src
			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)
Ejemplo n.º 4
0
        daemon.Daemon.init = init_patch

        # Monkey patch run method
        def run_patch(self):
            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)