def main(): global cachedir, cacheurl numgreenlets = 10 http_port = 8898 serve_files = True from mwlib import argv opts, args = argv.parse(sys.argv[1:], "--no-serve-files --serve-files-port= --serve-files --cachedir= --url= --numprocs=") for o, a in opts: if o == "--cachedir": cachedir = a elif o == "--url": cacheurl = a elif o == "--numprocs": numgreenlets = int(a) elif o == "--no-serve-files": serve_files = False elif o == "--serve-files-port": http_port = int(a) if cachedir is None: sys.exit("nslave.py: missing --cachedir argument") if serve_files: wsgi_server = start_serving_files(cachedir, http_port) port = wsgi_server.socket.getsockname()[1] if not cacheurl: cacheurl = "http://%s:%s/cache" % (find_ip(), port) print "serving files from %r at url %s" % (cachedir, cacheurl) if not cacheurl: sys.exit("--url option missing") make_cachedir(cachedir) from mwlib.async import slave slave.main(commands, numgreenlets=numgreenlets, argv=args)
def main(): global cachedir, cacheurl numgreenlets = 10 http_port = 8898 serve_files = True from mwlib import argv opts, args = argv.parse(sys.argv[1:], "--no-serve-files --serve-files-port= --serve-files --cachedir= --url= --numprocs=") for o, a in opts: if o == "--cachedir": cachedir = a elif o == "--url": cacheurl = a elif o == "--numprocs": numgreenlets = int(a) elif o == "--no-serve-files": serve_files = False elif o == "--serve-files-port": http_port = int(a) if cachedir is None: sys.exit("nslave: missing --cachedir argument") if serve_files: wsgi_server = start_serving_files(cachedir, http_port) port = wsgi_server.socket.getsockname()[1] if not cacheurl: cacheurl = "http://%s:%s/cache" % (find_ip(), port) print "serving files from %r at url %s" % (cachedir, cacheurl) if not cacheurl: sys.exit("--url option missing") make_cachedir(cachedir) from mwlib.async import slave slave.main(commands, numgreenlets=numgreenlets, argv=args)
def main(): global cachedir from mwlib import argv opts, args = argv.parse(sys.argv[1:], "--cachedir=") for o, a in opts: if o=="--cachedir": cachedir = a from mwlib.async import slave slave.main(commands, numgreenlets=32, argv=args)
def main(): # pywsgi.WSGIHandler.log_request = lambda *args, **kwargs: None from mwlib import argv opts, args = argv.parse( sys.argv[1:], "--disable-all-writers --qserve= --port= -i= --interface=") qs = [] port = 8899 interface = "0.0.0.0" for o, a in opts: if o == "--port": port = int(a) elif o == "--qserve": qs.append(a) elif o == "--disable-all-writers": name2writer.clear() elif o in ("-i", "--interface"): interface = a print "using the following writers", sorted(name2writer.keys()) qs += args if not qs: qs.append("localhost:14311") _parse_qs(qs) address = interface, port server = pywsgi.WSGIServer(address, default_app()) watchers = pool.Pool() for x in qs: watchers.spawn(call_in_loop(5.0, watch_qserve(x, busy))) try: print "listening on %s:%d" % address server.serve_forever() except KeyboardInterrupt: server.stop() print "bye."