66import argparse
77import check_requirements
88from utils .logger_utils import setup_logger
9+ import datetime
910
1011
1112# remove logs directory
12- os .system ( "rm -rf logs" )
13+ log_dir = os .path . join ( os . getcwd (), ' logs' , datetime . datetime . now (). strftime ( '%Y-%m-%d_%H-%M-%S' ) )
1314
1415# Set up logging
15- start_team_logger = setup_logger ('start-team' , 'logs/start-team.log' , console_level = logging .DEBUG , file_level = logging .DEBUG , console_format_str = '%(message)s' )
16+ start_team_logger = setup_logger ('start-team' , log_dir , console_level = logging .DEBUG , file_level = logging .DEBUG , console_format_str = '%(message)s' )
1617
1718def run_server_script (args ):
1819 # Start the server.py script as a new process group
1920 process = subprocess .Popen (
20- ['python3' , 'server.py' , '--rpc-port' , args .rpc_port ],
21+ ['python3' , 'server.py' , '--rpc-port' , args .rpc_port , '--log-dir' , log_dir ],
2122 preexec_fn = os .setsid , # Create a new session and set the process group ID
2223 stdout = subprocess .PIPE ,
2324 stderr = subprocess .STDOUT # Capture stderr and redirect it to stdout
@@ -43,7 +44,7 @@ def stream_output_to_console(process, prefix):
4344
4445def stream_output_to_file (process , prefix ):
4546 # Stream output from the process and log it with a prefix
46- logger = setup_logger (prefix , console_level = None , file_level = logging .DEBUG )
47+ logger = setup_logger (prefix , log_dir , console_level = None , file_level = logging .DEBUG )
4748 for line in iter (process .stdout .readline , b'' ):
4849 logger .info (line .decode ().strip ())
4950 pass
@@ -77,8 +78,8 @@ def kill_process_group(process):
7778 start_team_logger .debug (f"Started start.sh process with PID: { start_process .pid } with team name { args = } " )
7879
7980 # Monitor both processes and log their outputs
80- server_thread = threading .Thread (target = stream_output_to_console , args = (server_process , 'server: ' ))
81- start_thread = threading .Thread (target = stream_output_to_file , args = (start_process , 'proxy: ' ))
81+ server_thread = threading .Thread (target = stream_output_to_console , args = (server_process , 'server' ))
82+ start_thread = threading .Thread (target = stream_output_to_file , args = (start_process , 'proxy' ))
8283
8384 server_thread .start ()
8485 start_thread .start ()
0 commit comments