def really_main(opts, parent_pid=99999999999999): rebuild_cache() zeroconf = spydaap.zeroconf.Zeroconf(spydaap.server_name, spydaap.port, stype="_daap._tcp") zeroconf.publish() try: httpd = MyThreadedHTTPServer( ('0.0.0.0', spydaap.port), spydaap.server.makeDAAPHandlerClass(spydaap.server_name, cache, md_cache, container_cache)) # write pid to pidfile open(opts.pidfile, 'w').write("%d" % parent_pid) except socket.error: if not opts.daemonize: print "Another DAAP server is already running. Exiting." sys.exit(0) # silently exit; another instance is already running signal.signal(signal.SIGTERM, make_shutdown(httpd)) signal.signal(signal.SIGHUP, rebuild_cache) while httpd.keep_running: try: httpd.serve_forever() except select.error: pass except KeyboardInterrupt: httpd.force_stop() zeroconf.unpublish()
def really_main(): zeroconf = spydaap.zeroconf.Zeroconf( spydaap.server_name, spydaap.port, stype="_jpop._tcp", text = [spydaap.uniq, spydaap.white], ) zeroconf.publish() log.warn("Listening.") httpd = MyThreadedHTTPServer( ('0.0.0.0', spydaap.port), spydaap.server.DAAPHandler ) signal.signal(signal.SIGTERM, make_shutdown(httpd)) while httpd.keep_running: try: httpd.serve_forever() except select.error: pass except KeyboardInterrupt: httpd.force_stop() log.warn("Shutting down.") zeroconf.unpublish()
def really_main(opts, parent_pid=99999999999999): rebuild_cache() zeroconf = spydaap.zeroconf.Zeroconf(spydaap.server_name, spydaap.port, stype="_daap._tcp") zeroconf.publish() try: httpd = MyThreadedHTTPServer(('0.0.0.0', spydaap.port), spydaap.server.makeDAAPHandlerClass(spydaap.server_name, cache, md_cache, container_cache)) # write pid to pidfile open(opts.pidfile,'w').write("%d" % parent_pid) except socket.error: if not opts.daemonize: print "Another DAAP server is already running. Exiting." sys.exit(0) # silently exit; another instance is already running signal.signal(signal.SIGTERM, make_shutdown(httpd)) signal.signal(signal.SIGHUP, rebuild_cache) while httpd.keep_running: try: httpd.serve_forever() except select.error: pass except KeyboardInterrupt: httpd.force_stop() zeroconf.unpublish()
def really_main(): rebuild_cache() zeroconf = spydaap.zeroconf.Zeroconf(spydaap.server_name, spydaap.port, stype="_daap._tcp") zeroconf.publish() log.warn("Listening.") httpd = MyThreadedHTTPServer(('0.0.0.0', spydaap.port), spydaap.server.makeDAAPHandlerClass(spydaap.server_name, cache, md_cache, container_cache)) signal.signal(signal.SIGTERM, make_shutdown(httpd)) signal.signal(signal.SIGHUP, rebuild_cache) while httpd.keep_running: try: httpd.serve_forever() except select.error: pass except KeyboardInterrupt: httpd.force_stop() log.warn("Shutting down.") zeroconf.unpublish()