示例#1
0
def main():
    """ Main function which initializes and starts the tornado server. """
    # Parse command line arguments
    parser = argparse.ArgumentParser(description='A taskqueue API server')
    parser.add_argument('--port',
                        '-p',
                        default='17447',
                        help='TaskQueue server port')
    parser.add_argument('--verbose',
                        action='store_true',
                        help='Output debug-level logging')
    args = parser.parse_args()
    if args.verbose:
        logging.getLogger('appscale').setLevel(logging.DEBUG)

    # Configure zookeeper and db access
    zk_client = KazooClient(hosts=','.join(appscale_info.get_zk_node_ips()),
                            connection_retry=ZK_PERSISTENT_RECONNECTS)
    zk_client.start()
    db_access = DatastoreProxy()

    # Initialize tornado server
    task_queue = distributed_tq.DistributedTaskQueue(db_access, zk_client)
    tq_application = prepare_taskqueue_application(task_queue)
    # Automatically decompress incoming requests.
    server = httpserver.HTTPServer(tq_application, decompress_request=True)
    server.listen(args.port)

    # Make sure taskqueue shuts down gracefully when signal is received
    graceful_shutdown = prepare_graceful_shutdown(zk_client, server)
    signal.signal(signal.SIGTERM, graceful_shutdown)
    signal.signal(signal.SIGINT, graceful_shutdown)

    logger.info('Starting TaskQueue server on port {}'.format(args.port))
    ioloop.IOLoop.current().start()
 def test_distributed_tq_initialization():
     zk_client = MagicMock()
     lb_ips_patcher = patch(
         'appscale.common.appscale_info.get_load_balancer_ips',
         return_value=['192.168.0.1'])
     db_proxy_patcher = patch('appscale.common.appscale_info.get_db_proxy',
                              return_value=['192.168.0.1'])
     with lb_ips_patcher:
         with db_proxy_patcher:
             distributed_tq.DistributedTaskQueue(zk_client)
示例#3
0
 def test_distributed_tq_initialization():
   db_access = MagicMock()
   zk_client = MagicMock()
   distributed_tq.DistributedTaskQueue(db_access, zk_client)
示例#4
0
 def test_distributed_tq_initialization():
     zk_client = MagicMock()
     distributed_tq.DistributedTaskQueue(zk_client)