diff --git a/lib/process_manager.sh b/lib/process_manager.sh index 919a2d96..ea90bb62 100644 --- a/lib/process_manager.sh +++ b/lib/process_manager.sh @@ -17,15 +17,16 @@ should_generate_config() { # Helper function to parse and process each service configuration parse_service_info() { local service_json="$1" - local name=$(echo "$service_json" | jq -r '.name') - local command=$(echo "$service_json" | jq -r '.command') - local autostart=$(echo "$service_json" | jq -r '.autostart // "false"') - local autorestart=$(echo "$service_json" | jq -r '.autorestart // "false"') - local stderr_logfile=$(echo "$service_json" | jq -r '.stderr_logfile // ""') - local stdout_logfile=$(echo "$service_json" | jq -r '.stdout_logfile // ""') - local environment=$(echo "$service_json" | jq -r '.environment // [] | join(",")') + local name command autostart autorestart stderr_logfile stdout_logfile 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(",")') - # For each service, replace placeholders and append to FINAL_CONFIG sed "s|\${process_name}|$name|g; \ s|\${command}|$command|g; \ s|\${autostart}|$autostart|g; \ diff --git a/src/scripts/process_example.sh b/src/scripts/process_example.sh index 175897b9..e786ee67 100644 --- a/src/scripts/process_example.sh +++ b/src/scripts/process_example.sh @@ -1,10 +1,10 @@ #!/bin/bash -# Script to run as a systemd service in a loop +# Script to run as a supervisor service in a loop end_time=$(($(date +%s) + 30)) # Calculate end_time as current epoch time plus 30 seconds. -while [ $(date +%s) -lt $end_time ]; do +while [ "$(date +%s)" -lt $end_time ]; do echo "Service is running at $(date)" sleep 5 done