[supervisord]
nodaemon=true
logfile=/dev/null
pidfile=/var/run/supervisord.pid

; --- Database Init ---
[program:initdb]
directory=/app/server
command=/usr/local/bin/python database.py
autostart=true
autorestart=false
startsecs=0
stdout_logfile=/dev/stdout
stderr_logfile=/dev/stderr
stdout_logfile_maxbytes=0
stderr_logfile_maxbytes=0
priority=5

; --- Flask API (gunicorn) ---
[program:api]
directory=/app/server
command=/usr/local/bin/gunicorn --bind %(ENV_API_BIND)s --workers 2 --threads 4 app:app
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stderr_logfile=/dev/stderr
stdout_logfile_maxbytes=0
stderr_logfile_maxbytes=0
startsecs=2
stopasgroup=true
killasgroup=true

; --- Flet web app ---
; If your app reads API URL from env, set it here as a relative path (/api)
[program:flet]
directory=/app/client
command=/usr/local/bin/python main.py
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stderr_logfile=/dev/stderr
stdout_logfile_maxbytes=0
stderr_logfile_maxbytes=0
startsecs=2
stopasgroup=true
killasgroup=true

; --- Nginx (foreground) ---
[program:nginx]
command=/usr/sbin/nginx -g 'daemon off;'
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stderr_logfile=/dev/stderr
stdout_logfile_maxbytes=0
stderr_logfile_maxbytes=0
startsecs=2
stopasgroup=true
killasgroup=true