@@ -308,6 +308,7 @@ def _script_replacement(self, key, value):
308
308
309
309
rewrites = [("GET" , "/resources/WebIDLParser.js" , "/resources/webidl2/lib/webidl2.js" )]
310
310
311
+
311
312
class RoutesBuilder (object ):
312
313
def __init__ (self ):
313
314
self .forbidden_override = [("GET" , "/tools/runner/*" , handlers .file_handler ),
@@ -501,7 +502,7 @@ def make_hosts_file(config, host):
501
502
def start_servers (host , ports , paths , routes , bind_address , config , ** kwargs ):
502
503
servers = defaultdict (list )
503
504
for scheme , ports in ports .items ():
504
- assert len (ports ) == {"http" :2 }.get (scheme , 1 )
505
+ assert len (ports ) == {"http" : 2 }.get (scheme , 1 )
505
506
506
507
# If trying to start HTTP/2.0 server, check compatibility
507
508
if scheme == 'http2' and not http2_compatible ():
@@ -512,11 +513,11 @@ def start_servers(host, ports, paths, routes, bind_address, config, **kwargs):
512
513
for port in ports :
513
514
if port is None :
514
515
continue
515
- init_func = {"http" :start_http_server ,
516
- "https" :start_https_server ,
517
- "http2" :start_http2_server ,
518
- "ws" :start_ws_server ,
519
- "wss" :start_wss_server }[scheme ]
516
+ init_func = {"http" : start_http_server ,
517
+ "https" : start_https_server ,
518
+ "http2" : start_http2_server ,
519
+ "ws" : start_ws_server ,
520
+ "wss" : start_wss_server }[scheme ]
520
521
521
522
server_proc = ServerProc (scheme = scheme )
522
523
server_proc .start (init_func , host , port , paths , routes , bind_address ,
@@ -570,6 +571,8 @@ def start_http2_server(host, port, paths, routes, bind_address, config, **kwargs
570
571
encrypt_after_connect = config .ssl_config ["encrypt_after_connect" ],
571
572
latency = kwargs .get ("latency" ),
572
573
http2 = True )
574
+
575
+
573
576
class WebSocketDaemon (object ):
574
577
def __init__ (self , host , port , doc_root , handlers_root , log_level , bind_address ,
575
578
ssl_config ):
@@ -601,6 +604,17 @@ def __init__(self, host, port, doc_root, handlers_root, log_level, bind_address,
601
604
opts , args = pywebsocket ._parse_args_and_config (cmd_args )
602
605
opts .cgi_directories = []
603
606
opts .is_executable_method = None
607
+
608
+ # Logging needs to be configured both before and after reloading,
609
+ # because some modules store loggers as global variables.
610
+ pywebsocket ._configure_logging (opts )
611
+ # Ensure that when we start this in a new process we have the global
612
+ # lock in the logging module unlocked.
613
+ reload_module (logging )
614
+ release_mozlog_lock ()
615
+ pywebsocket ._configure_logging (opts )
616
+ # DO NOT LOG BEFORE THIS LINE.
617
+
604
618
self .server = pywebsocket .WebSocketServer (opts )
605
619
ports = [item [0 ].getsockname ()[1 ] for item in self .server ._sockets ]
606
620
assert all (item == ports [0 ] for item in ports )
@@ -647,29 +661,21 @@ def release_mozlog_lock():
647
661
648
662
649
663
def start_ws_server (host , port , paths , routes , bind_address , config , ** kwargs ):
650
- # Ensure that when we start this in a new process we have the global lock
651
- # in the logging module unlocked
652
- reload_module (logging )
653
- release_mozlog_lock ()
654
664
return WebSocketDaemon (host ,
655
665
str (port ),
656
666
repo_root ,
657
667
config .paths ["ws_doc_root" ],
658
- "debug" ,
668
+ config . log_level . lower () ,
659
669
bind_address ,
660
- ssl_config = None )
670
+ ssl_config = None )
661
671
662
672
663
673
def start_wss_server (host , port , paths , routes , bind_address , config , ** kwargs ):
664
- # Ensure that when we start this in a new process we have the global lock
665
- # in the logging module unlocked
666
- reload_module (logging )
667
- release_mozlog_lock ()
668
674
return WebSocketDaemon (host ,
669
675
str (port ),
670
676
repo_root ,
671
677
config .paths ["ws_doc_root" ],
672
- "debug" ,
678
+ config . log_level . lower () ,
673
679
bind_address ,
674
680
config .ssl_config )
675
681
@@ -726,9 +732,11 @@ def build_config(override_path=None, **kwargs):
726
732
727
733
return rv
728
734
735
+
729
736
def _make_subdomains_product (s , depth = 2 ):
730
737
return {u"." .join (x ) for x in chain (* (product (s , repeat = i ) for i in range (1 , depth + 1 )))}
731
738
739
+
732
740
_subdomains = {u"www" ,
733
741
u"www1" ,
734
742
u"www2" ,
@@ -745,7 +753,8 @@ def _make_subdomains_product(s, depth=2):
745
753
class ConfigBuilder (config .ConfigBuilder ):
746
754
"""serve config
747
755
748
- this subclasses wptserve.config.ConfigBuilder to add serve config options"""
756
+ This subclasses wptserve.config.ConfigBuilder to add serve config options.
757
+ """
749
758
750
759
_default = {
751
760
"browser_host" : "web-platform.test" ,
0 commit comments