def main(): global ready # to profile gae_proxy, run proxy.py, visit some web by proxy, then visit http://127.0.0.1:8084/quit to quit and print result. do_profile = False if do_profile: import cProfile, pstats pr = cProfile.Profile() pr.enable() global __file__ __file__ = os.path.abspath(__file__) if os.path.islink(__file__): __file__ = getattr(os, 'readlink', lambda x: x)(__file__) os.chdir(os.path.dirname(os.path.abspath(__file__))) xlog.basicConfig( level=xlog.DEBUG if config.LISTEN_DEBUGINFO else xlog.INFO, format='%(levelname)s - %(asctime)s %(message)s', datefmt='[%b %d %H:%M:%S]') pre_start() xlog.info(config.info()) CertUtil.init_ca() proxy_daemon = LocalProxyServer((config.LISTEN_IP, config.LISTEN_PORT), proxy_handler.GAEProxyHandler) proxy_thread = threading.Thread(target=proxy_daemon.serve_forever) proxy_thread.setDaemon(True) proxy_thread.start() if config.PAC_ENABLE: pac_daemon = LocalProxyServer((config.PAC_IP, config.PAC_PORT), pac_server.PACServerHandler) pac_thread = threading.Thread(target=pac_daemon.serve_forever) pac_thread.setDaemon(True) pac_thread.start() ready = True #checked by launcher.module_init while connect_control.keep_running: time.sleep(1) xlog.info("Exiting gae_proxy module...") proxy_daemon.shutdown() proxy_daemon.server_close() proxy_thread.join() if config.PAC_ENABLE: pac_daemon.shutdown() pac_daemon.server_close() pac_thread.join() ready = False #checked by launcher.module_init xlog.info("Finished Exiting gae_proxy module...") if do_profile: pr.disable() pr.print_stats()
def main(): global ready connect_control.keep_running = True config.load() connect_manager.https_manager.load_config() xlog.debug("## GAEProxy set keep_running: %s", connect_control.keep_running) # to profile gae_proxy, run proxy.py, visit some web by proxy, then visit http://127.0.0.1:8084/quit to quit and print result. do_profile = False if do_profile: import cProfile, pstats pr = cProfile.Profile() pr.enable() global __file__ __file__ = os.path.abspath(__file__) if os.path.islink(__file__): __file__ = getattr(os, 'readlink', lambda x: x)(__file__) os.chdir(os.path.dirname(os.path.abspath(__file__))) xlog.basicConfig(level=xlog.DEBUG if config.LISTEN_DEBUGINFO else xlog.INFO, format='%(levelname)s - %(asctime)s %(message)s', datefmt='[%b %d %H:%M:%S]') pre_start() log_info() CertUtil.init_ca() proxy_daemon = simple_http_server.HTTPServer((config.LISTEN_IP, config.LISTEN_PORT), proxy_handler.GAEProxyHandler) proxy_thread = threading.Thread(target=proxy_daemon.serve_forever) proxy_thread.setDaemon(True) proxy_thread.start() if config.PAC_ENABLE: pac_daemon = simple_http_server.HTTPServer((config.PAC_IP, config.PAC_PORT), pac_server.PACServerHandler) pac_thread = threading.Thread(target=pac_daemon.serve_forever) pac_thread.setDaemon(True) pac_thread.start() ready = True # checked by launcher.module_init while connect_control.keep_running: time.sleep(1) xlog.info("Exiting gae_proxy module...") proxy_daemon.shutdown() proxy_daemon.server_close() proxy_thread.join() if config.PAC_ENABLE: pac_daemon.shutdown() pac_daemon.server_close() pac_thread.join() ready = False # checked by launcher.module_init xlog.debug("## GAEProxy set keep_running: %s", connect_control.keep_running) if do_profile: pr.disable() pr.print_stats()