def main(): parser = optparse.OptionParser("Usage: %prog PID") parser.add_option( '-p', '--port', default=port, type="int", help="The port to listen on for console connections", ) options, args = parser.parse_args() if not args: parser.print_usage() raise SystemExit(1) if args[0] == 'dummy': print "PID", os.getpid() def wait_for_signal(): log = diesel.log.name('dummy') log.min_level = diesel.loglevels.INFO install_console_signal_handler() while True: log.info("sleeping") diesel.sleep(5) diesel.quickstart(wait_for_signal) else: pid = int(args[0]) svc = diesel.Service(console_for(pid), options.port) diesel.quickstart(svc)
def main(server_port): app = diesel.Application() server = EchoServer() app.add_service(diesel.Service(server.handler, server_port)) try: app.run() except: print "exit."
def main(server_port): app = diesel.Application() server = EchoServer() app.add_service(diesel.Service(server.handler, server_port)) app.run() if _name_ == "main_": parser = argparse.ArgumentParser( description="Echo Server example with diesel") parser.add.argument("--port", action - "store", dest - "port", type=int, required=True) given_args = parser.parse_args() port = given_args.port
def main(server_port): app = diesel.Application() server = EchoServer() app.add_service(diesel.Service(server.handler, server_port)) app.run()
def start_service(iface, port, whois): """ Start the service. """ diesel.quickstart( diesel.Service(functools.partial(respond, whois), port, iface))