def main(): global glb parser = OptionParser() parser.add_option("-c", "--config", dest="config", help="Config file", default="config.cfg") parser.add_option("-p", "--port", dest="port", help="Queue port number", default=9000) parser.add_option('-l', '--log-filename', dest='log', help="Log filename (use '-' for stderr)", default="-") (options, args) = parser.parse_args() config.loadConfig(options.config) config.setupLogging(options.log) model_manager.setupModels() model_manager.startScannerThread() if not os.path.exists(os.path.dirname(config.queueFile)): logging.warning("Queue directory does not exist, attempting to create") os.makedirs(os.path.dirname(config.queueFile)) try: queueShelve = shelve.open(config.queueFile) except anydbm.error: logging.warning("Queue file '%s' is corrupt, removing and starting afresh", config.queueFile) os.remove(config.queueFile) queueShelve = shelve.open(config.queueFile) try: glb = QueueGlobals(queueShelve) queueHTTP = tornado.httpserver.HTTPServer(tornado.web.Application([ (r"/worker_info", WorkerInfo), (r"/client_model_create", ClientModelCreate), (r"/client_queue_has_workers", ClientQueueHasWorkers), (r"/client_confirm/(\w+)", ClientConfirm), (r"/worker_failed_task/(\d+)", WorkerFailedTask), (r"/worker_succeed_task/(\d+)", WorkerSucceededTask), (r"/worker_has_task/(\d+)", WorkerHasTask), (r"/worker_keep_alive_task/(\d+)", WorkerTaskKeepAlive), (r"/worker_work_task", WorkerTaskRequest) ])) queueHTTP.listen(options.port) logging.info("NPSGD Queue Booted up, serving on port %d", options.port) print >>sys.stderr, "NPSGD queue server listening on %d" % options.port tornado.ioloop.IOLoop.instance().start() finally: queueShelve.close()
def main(): parser = OptionParser() parser.add_option('-c', '--config', dest="config", help="Configuration file path", type="string", default="config.cfg") parser.add_option('-l', '--log-filename', dest='log', help="Log filename (use '-' for stderr)", default="-") (options, args) = parser.parse_args() config.loadConfig(options.config) config.setupLogging(options.log) model_manager.setupModels() model_manager.startScannerThread() worker = NPSGDWorker(config.queueServerAddress, config.queueServerPort) logging.info("NPSGD Worker booted up, going into event loop") worker.getServerInfo() worker.loop()
def main(): parser = OptionParser() parser.add_option('-c', '--config', dest='config', help="Config file", default="config.cfg") parser.add_option('-p', '--client-port', dest='port', help="Http port (for serving html)", default=8000, type="int") parser.add_option('-l', '--log-filename', dest='log', help="Log filename (use '-' for stderr)", default="-") (options, args) = parser.parse_args() config.loadConfig(options.config) config.setupLogging(options.log) model_manager.setupModels() model_manager.startScannerThread() clientHTTP = tornado.httpserver.HTTPServer(setupClientApplication()) clientHTTP.listen(options.port) logging.info("NPSGD Web Booted up, serving on port %d", options.port) print >>sys.stderr, "NPSGD web server running on port %d" % options.port tornado.ioloop.IOLoop.instance().start()