Skip to content

Commit

Permalink
simplified yml config
Browse files Browse the repository at this point in the history
  • Loading branch information
fqjony committed Dec 27, 2024
1 parent 86c947b commit 3294161
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
30 changes: 15 additions & 15 deletions etc/home/supervisor.default
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
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}
6 changes: 1 addition & 5 deletions lib/process_manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
4 changes: 0 additions & 4 deletions src/configs/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ 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"
- name: "another_service"
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

Check warning on line 16 in src/configs/services.yml

View workflow job for this annotation

GitHub Actions / Analyze YAML Files

16:21 [comments] too few spaces before comment

0 comments on commit 3294161

Please sign in to comment.