def run_server(config): listening_port = config['web']['port'].get(int) ws_server = WebSocketServer(port=listening_port + 1) setup_app(config) setup_logging(config) setup_task_queue(config) setup_signals(ws_server) consumer = Consumer(task_queue) ip_address = get_ip_address() if (app.config['standalone'] and ip_address and config['driver'].get() == 'chdkcamera'): # Display the address of the web interface on the camera displays try: for cam in plugin.get_devices(config): cam.show_textbox( "\n You can now access the web interface at:" "\n\n\n http://{0}:{1}".format( ip_address, listening_port)) except plugin.DeviceException: logger.warn("No devices could be found at startup.") # Start task consumer consumer.start() # Start websocket server ws_server.start() if app.config['mode'] in ('processor', 'full'): discovery_listener = DiscoveryListener(listening_port) discovery_listener.start() try: import waitress waitress.serve(app, port=listening_port) finally: consumer.shutdown() ws_server.stop() if app.config['mode'] in ('processor', 'full'): discovery_listener.stop()
def run_server(config): listening_port = config['web']['port'].get(int) ws_server = WebSocketServer(port=listening_port+1) setup_app(config) setup_logging(config) setup_task_queue(config) setup_signals(ws_server) consumer = Consumer(task_queue) ip_address = get_ip_address() if (app.config['standalone'] and ip_address and config['driver'].get() == 'chdkcamera'): # Display the address of the web interface on the camera displays try: for cam in plugin.get_devices(config): cam.show_textbox( "\n You can now access the web interface at:" "\n\n\n http://{0}:{1}" .format(ip_address, listening_port)) except plugin.DeviceException: logger.warn("No devices could be found at startup.") # Start task consumer consumer.start() # Start websocket server ws_server.start() if app.config['mode'] in ('processor', 'full'): discovery_listener = DiscoveryListener(listening_port) discovery_listener.start() try: import waitress waitress.serve(app, port=listening_port) finally: consumer.shutdown() ws_server.stop() if app.config['mode'] in ('processor', 'full'): discovery_listener.stop()
def run_server(config): ws_server = WebSocketServer(port=5001) setup_app(config) setup_logging(config) setup_signals(ws_server) # Initialize huey task queue global task_queue db_location = os.path.join(config.config_dir(), 'queue.db') task_queue = SqliteHuey(location=db_location) consumer = Consumer(task_queue) ip_address = get_ip_address() if (app.config['standalone'] and ip_address and config['driver'].get() in ['chdkcamera', 'a2200']): # Display the address of the web interface on the camera displays try: for cam in get_devices(config): cam.show_textbox( "\n You can now access the web interface at:" "\n\n\n http://{0}:5000".format(ip_address)) except: logger.warn("No devices could be found at startup.") # Start task consumer consumer.start() # Start websocket server ws_server.start() try: import waitress # NOTE: We spin up this obscene number of threads since we have # some long-polling going on, which will always block # one worker thread. waitress.serve(app, port=5000, threads=16) finally: consumer.shutdown() ws_server.stop()
def run_server(config): ws_server = WebSocketServer(port=5001) setup_app(config) setup_logging(config) setup_signals(ws_server) # Initialize huey task queue global task_queue db_location = config.cfg_path.parent / 'queue.db' task_queue = SqliteHuey(location=unicode(db_location)) consumer = Consumer(task_queue) ip_address = get_ip_address() if (app.config['standalone'] and ip_address and config['driver'].get() == 'chdkcamera'): # Display the address of the web interface on the camera displays try: for cam in plugin.get_devices(config): cam.show_textbox( "\n You can now access the web interface at:" "\n\n\n http://{0}:5000".format(ip_address)) except plugin.DeviceException: logger.warn("No devices could be found at startup.") # Start task consumer consumer.start() # Start websocket server ws_server.start() try: import waitress # NOTE: We spin up this obscene number of threads since we have # some long-polling going on, which will always block # one worker thread. waitress.serve(app, port=5000, threads=16) finally: consumer.shutdown() ws_server.stop()