; Notes:
; priority=1 --> Lower priorities indicate programs that start first and shut down last
; killasgroup=true --> send kill signal to child processes too
[supervisord]
environment=PYTHONUNBUFFERED="1", SENTRY_DSN="https://0b59ca68d333c62aa1f4b4f47fc0b9e5@sentry.jingrow.cloud/2", FRAPPE_SENTRY_DSN="https://0b59ca68d333c62aa1f4b4f47fc0b9e5@sentry.jingrow.cloud/2", PATH="/home/jingrow/.local/bin:/home/jingrow/.nvm/versions/node/v18.17.1/bin:/home/jingrow/.pyenv/plugins/pyenv-virtualenv/shims:/home/jingrow/.pyenv/shims:/home/jingrow/.pyenv/bin::%(ENV_PATH)s", SENTRY_TRACING_SAMPLE_RATE="1", ENABLE_SENTRY_DB_MONITORING="1"

; graceful timeout should always be lower than stopwaitsecs to avoid orphan gunicorn workers.
[program:jingrow-bench-jingrow-web]
command=/home/jingrow/jingrow-bench/env/bin/gunicorn -b 127.0.0.1:8000 -w 32 --threads=8 -k gthread --max-requests 5000 --max-requests-jitter 500 -t 60 --graceful-timeout 30 jingrow.app:application --statsd-host=10.139.212.189:9125 --statsd-prefix=jcloude
priority=4
autostart=true
autorestart=true
stdout_logfile=/home/jingrow/jingrow-bench/logs/web.log
stderr_logfile=/home/jingrow/jingrow-bench/logs/web.error.log
stopwaitsecs=40
user=jingrow
directory=/home/jingrow/jingrow-bench/sites


[program:jingrow-bench-jingrow-schedule]
command=/home/jingrow/.pyenv/versions/3.10.0/bin/bench schedule
priority=3
autostart=true
stdout_logfile=/home/jingrow/jingrow-bench/logs/schedule.log
stderr_logfile=/home/jingrow/jingrow-bench/logs/schedule.error.log
user=jingrow
directory=/home/jingrow/jingrow-bench


[program:jingrow-bench-jingrow-default-worker]
command=bash -c "/home/jingrow/jingrow-bench/apps/jcloude/deployment/wait-for-redis.sh && /home/jingrow/.pyenv/versions/3.10.0/bin/bench worker-pool --num-workers 8 --queue default"
priority=4
autostart=true
autorestart=true
stdout_logfile=/home/jingrow/jingrow-bench/logs/default-worker.log
stderr_logfile=/home/jingrow/jingrow-bench/logs/default-worker.error.log
user=jingrow
stopwaitsecs=360
directory=/home/jingrow/jingrow-bench
killasgroup=true
environment=FRAPPE_BACKGROUND_WORKERS_NOFORK="True"
process_name=%(program_name)s

[program:jingrow-bench-jingrow-short-worker]
command=bash -c "/home/jingrow/jingrow-bench/apps/jcloude/deployment/wait-for-redis.sh && /home/jingrow/.pyenv/versions/3.10.0/bin/bench worker-pool --num-workers 24 --queue short,default"
priority=4
autostart=true
autorestart=true
stdout_logfile=/home/jingrow/jingrow-bench/logs/short-worker.log
stderr_logfile=/home/jingrow/jingrow-bench/logs/short-worker.error.log
user=jingrow
stopwaitsecs=360
directory=/home/jingrow/jingrow-bench
killasgroup=true
environment=FRAPPE_BACKGROUND_WORKERS_NOFORK="True"
process_name=%(program_name)s


[program:jingrow-bench-jingrow-long-worker]
command=bash -c "/home/jingrow/jingrow-bench/apps/jcloude/deployment/wait-for-redis.sh && /home/jingrow/.pyenv/versions/3.10.0/bin/bench worker-pool --num-workers 16 --queue default,short,long"
priority=4
autostart=true
autorestart=true
stdout_logfile=/home/jingrow/jingrow-bench/logs/long-worker.log
stderr_logfile=/home/jingrow/jingrow-bench/logs/long-worker.error.log
user=jingrow
stopwaitsecs=1560
directory=/home/jingrow/jingrow-bench
killasgroup=true
environment=FRAPPE_BACKGROUND_WORKERS_NOFORK="True"
process_name=%(program_name)s


[program:jingrow-bench-jingrow-sync-worker]
command=bash -c "/home/jingrow/jingrow-bench/apps/jcloude/deployment/wait-for-redis.sh && /home/jingrow/.pyenv/versions/3.10.0/bin/bench worker-pool --num-workers 6 --queue sync,long,default,short"
priority=4
autostart=true
autorestart=true
stdout_logfile=/home/jingrow/jingrow-bench/logs/sync-worker.log
stderr_logfile=/home/jingrow/jingrow-bench/logs/sync-worker.error.log
user=jingrow
stopwaitsecs=1560
directory=/home/jingrow/jingrow-bench
killasgroup=true
environment=FRAPPE_BACKGROUND_WORKERS_NOFORK="True"
process_name=%(program_name)s



# Build worker, used to run jcloude side of builds
# i.e tarring and uploading the build context.
[program:jingrow-bench-jingrow-build-worker]
command=bash -c "/home/jingrow/jingrow-bench/apps/jcloude/deployment/wait-for-redis.sh && /home/jingrow/.pyenv/versions/3.10.0/bin/bench worker-pool --num-workers 8 --queue build"
priority=4
autostart=true
autorestart=true
stdout_logfile=/home/jingrow/jingrow-bench/logs/build-worker.log
stderr_logfile=/home/jingrow/jingrow-bench/logs/build-worker.error.log
user=jingrow
stopwaitsecs=120
directory=/home/jingrow/jingrow-bench
killasgroup=true
process_name=%(program_name)s


[program:jingrow-bench-redis-cache]
command=/usr/bin/redis-server /home/jingrow/jingrow-bench/config/redis_cache.conf
priority=1
autostart=true
autorestart=true
stdout_logfile=/home/jingrow/jingrow-bench/logs/redis-cache.log
stderr_logfile=/home/jingrow/jingrow-bench/logs/redis-cache.error.log
user=jingrow
directory=/home/jingrow/jingrow-bench/sites


[program:jingrow-bench-redis-queue]
command=/usr/bin/redis-server /home/jingrow/jingrow-bench/config/redis_queue.conf
priority=1
autostart=true
autorestart=true
stdout_logfile=/home/jingrow/jingrow-bench/logs/redis-queue.log
stderr_logfile=/home/jingrow/jingrow-bench/logs/redis-queue.error.log
user=jingrow
directory=/home/jingrow/jingrow-bench/sites


[program:jingrow-bench-node-socketio]
command=/home/jingrow/.nvm/versions/node/v18.17.1/bin/node /home/jingrow/jingrow-bench/apps/jingrow/socketio.js
priority=4
autostart=true
autorestart=true
stdout_logfile=/home/jingrow/jingrow-bench/logs/node-socketio.log
stderr_logfile=/home/jingrow/jingrow-bench/logs/node-socketio.error.log
user=jingrow
directory=/home/jingrow/jingrow-bench


[group:jingrow-bench-web]
programs=jingrow-bench-jingrow-web

[group:jingrow-bench-socket]
programs=jingrow-bench-node-socketio


[group:jingrow-bench-workers]
programs=jingrow-bench-jingrow-schedule,jingrow-bench-jingrow-short-worker,jingrow-bench-jingrow-long-worker,jingrow-bench-jingrow-default-worker

[group:jingrow-bench-chill-workers]
programs=jingrow-bench-jingrow-build-worker,jingrow-bench-jingrow-sync-worker


[group:jingrow-bench-redis]
programs=jingrow-bench-redis-cache,jingrow-bench-redis-queue
