diff --git a/etc/home/supervisor.default b/etc/home/supervisor.default index cb4fbe0c..b938145a 100644 --- a/etc/home/supervisor.default +++ b/etc/home/supervisor.default @@ -1,15 +1,15 @@ [supervisord] -logfile=/var/log/supervisor/supervisord.log ; Logfile path -logfile_maxbytes=50MB ; Maximum log file bytes before rotating -logfile_backups=10 ; Number of backups to keep -loglevel=info ; Log level (info, debug, warn, trace) -pidfile=/var/run/supervisor/supervisord.pid ; Location of the PID file -nodaemon=false ; Run in the foreground (Docker best practice) -minfds=1024 ; Minimum number of file descriptors -minprocs=200 ; Minimum number of processes +logfile=/var/log/supervisor/supervisord.log +logfile_maxbytes=50MB +logfile_backups=10 +loglevel=info +pidfile=/var/run/supervisor/supervisord.pid +nodaemon=false +minfds=1024 +minprocs=200 [supervisorctl] -serverurl=unix:///var/run/supervisor/supervisord.sock ; Path to the UNIX socket for supervisorctl to connect to supervisord +serverurl=unix:///var/run/supervisor/supervisord.sock [unix_http_server] file=/var/run/supervisor/supervisord.sock ; path to your socket file @@ -18,9 +18,9 @@ file=/var/run/supervisor/supervisord.sock ; path to your socket file supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [program:${process_name}] -command=${command} ; Command to start the process -autostart=${autostart} ; Whether to start the process at supervisord start -autorestart=${autorestart} ; Whether to restart the process on exit -stderr_logfile=${stderr_logfile} ; Path for stderr logfile -stdout_logfile=${stdout_logfile} ; Path for stdout logfile -environment=${envs} ; Environment variables \ No newline at end of file +command=${command} +autostart=${autostart} +autorestart=${autorestart} +stderr_logfile=/var/log/supervisor/${process_name}.err.log +stdout_logfile=/var/log/supervisor/${process_name}.out.log +environment=${envs} diff --git a/lib/process_manager.sh b/lib/process_manager.sh index e136758c..42d947b6 100644 --- a/lib/process_manager.sh +++ b/lib/process_manager.sh @@ -17,22 +17,18 @@ should_generate_config() { # Helper function to parse and process each service configuration parse_service_info() { local service_json="$1" - local name command autostart autorestart stderr_logfile stdout_logfile environment + local name command autostart autorestart environment name=$(echo "$service_json" | jq -r '.name') command=$(echo "$service_json" | jq -r '.command') autostart=$(echo "$service_json" | jq -r '.autostart // "false"') autorestart=$(echo "$service_json" | jq -r '.autorestart // "false"') - stderr_logfile=$(echo "$service_json" | jq -r '.stderr_logfile // ""') - stdout_logfile=$(echo "$service_json" | jq -r '.stdout_logfile // ""') environment=$(echo "$service_json" | jq -r '.environment // [] | join(",")') sed "s|\${process_name}|$name|g; \ s|\${command}|$command|g; \ s|\${autostart}|$autostart|g; \ s|\${autorestart}|$autorestart|g; \ - s|\${stderr_logfile}|$stderr_logfile|g; \ - s|\${stdout_logfile}|$stdout_logfile|g; \ s|\${envs}|$environment|g" "$TEMPLATE_FILE" >> "$FINAL_CONFIG" } diff --git a/src/configs/services.yml b/src/configs/services.yml index 7587a219..91ce27c9 100644 --- a/src/configs/services.yml +++ b/src/configs/services.yml @@ -6,8 +6,6 @@ services: command: "sh /usr/local/scripts/process_example.sh" autostart: "true" autorestart: "false" - stderr_logfile: "/var/log/supervisor/webapp.err.log" - stdout_logfile: "/var/log/supervisor/webapp.out.log" environment: - "KEY1=value1" - "KEY2=value2" @@ -15,6 +13,4 @@ services: command: "sh /usr/local/scripts/process_example.sh" autostart: "true" autorestart: "true" - stderr_logfile: "/var/log/supervisor/webapp2.err.log" - stdout_logfile: "/var/log/supervisor/webapp2.out.log" environment: [] # Even if empty, define it as an empty array