11from dotenv import load_dotenv
2+ import os
23import shutil
34import signal
45import sys
89
910
1011def init_runtime ():
11- if len (sys .argv ) > 1 :
12- logging .info ("Loading config file %s" , sys .argv [1 ])
13- config_file = sys .argv [1 ]
14- else :
15- logging .info ("Loading default config file %s" , ".env" )
16- config_file = None
17- load_dotenv (config_file )
18- signal .signal (signal .SIGCHLD , signal .SIG_IGN )
19- set_docker_available (shutil .which ("docker" ) is not None )
20-
12+
2113 logging .basicConfig (
2214 level = logging .INFO ,
2315 format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" ,
@@ -29,6 +21,20 @@ def init_runtime():
2921
3022 logger = logging .getLogger ("moteur-server" )
3123
24+ # Config file from environment variable
25+ config_file = os .environ .get ("MSR_CONF_FILE" )
26+ if config_file :
27+ logging .info ("Loading config file %s" , config_file )
28+ else :
29+ logging .info ("Loading default config file %s" , ".env" )
30+ config_file = None
31+
32+ # Load environment from the specified file
33+ load_dotenv (config_file )
34+
35+ signal .signal (signal .SIGCHLD , signal .SIG_IGN )
36+ set_docker_available (shutil .which ("docker" ) is not None )
37+
3238 def log_uncaught_exceptions (exc_type , exc_value , exc_traceback ):
3339 if issubclass (exc_type , KeyboardInterrupt ):
3440 sys .__excepthook__ (exc_type , exc_value , exc_traceback )
0 commit comments