; The supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Notes:
;  - Shell expansion ("~" or "$HOME") is not supported.  Environment
;    variables can be expanded using this syntax: "%(ENV_HOME)s".
;  - Quotes around values are not supported, except in the case of
;    the environment= options as shown below.
;  - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
;  - Command will be truncated if it looks like a config file comment, e.g.
;    "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ".

[unix_http_server]
file=/tmp/supervisor.sock   ; the path to the socket file
;chmod=0700                 ; socket file mode (default 0700)
;chown=nobody:nogroup       ; socket file uid:gid owner
;username=user              ; default is no username (open server)
;password=123               ; default is no password (open server)

;[inet_http_server]         ; inet (TCP) server disabled by default
;port=127.0.0.1:9001        ; ip_address:port specifier, *:port for all iface
;username=user              ; default is no username (open server)
;password=123               ; default is no password (open server)

[supervisord]
logfile=logs/supervisord.log ; main log file; default $CWD/supervisord.log
logfile_maxbytes=50MB        ; max main logfile bytes b4 rotation; default 50MB
logfile_backups=10           ; # of main logfile backups; 0 means none, default 10
loglevel=info                ; log level; default info; others: debug,warn,trace
pidfile=pids/supervisord.pid ; supervisord pidfile; default supervisord.pid
nodaemon=false               ; start in foreground if true; default false
minfds=1024                  ; min. avail startup file descriptors; default 1024
minprocs=200                 ; min. avail process descriptors;default 200
;umask=022                   ; process file creation umask; default 022
;user=supervisord            ; setuid to this UNIX account at startup; recommended if root
;identifier=supervisor       ; supervisord identifier, default is 'supervisor'
;directory=/tmp              ; default is not to cd during start
;nocleanup=true              ; don't clean up tempfiles at start; default false
;childlogdir=/tmp            ; 'AUTO' child log dir, default $TEMP
;environment=KEY="value"     ; key value pairs to add to environment
;strip_ansi=false            ; strip ansi escape codes in logs; def. false

; The rpcinterface:supervisor section must remain in the config file for
; RPC (supervisorctl/web interface) to work.  Additional interfaces may be
; added by defining them in separate [rpcinterface:x] sections.

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

; The supervisorctl section configures how supervisorctl will connect to
; supervisord.  configure it match the settings in either the unix_http_server
; or inet_http_server section.

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=chris              ; should be same as in [*_http_server] if set
;password=123                ; should be same as in [*_http_server] if set
;prompt=mysupervisor         ; cmd line prompt (default "supervisor")
;history_file=~/.sc_history  ; use readline history if available


[program:webserver]
command=gunicorn --pid gunicorn.pid -w 4 -b 0.0.0.0:%(ENV_WEBSERVER_PORT)s km3mon:app
stdout_logfile=logs/%(program_name)s.out.log        ; stdout log path, NONE for none; default AUTO
stderr_logfile=logs/%(program_name)s.err.log        ; stderr log path, NONE for none; default AUTO

[program:monitoring_ligier]
command=%(ENV_LIGIER_CMD)s -d3 -P %(ENV_MONITORING_LIGIER_PORT)s
priority=1
stdout_logfile=logs/%(program_name)s.out.log        ; stdout log path, NONE for none; default AUTO
stderr_logfile=logs/%(program_name)s.err.log        ; stderr log path, NONE for none; default AUTO

[program:ligiermirror]
command=ligiermirror -m "%(ENV_TAGS_TO_MIRROR)s" -q %(ENV_MONITORING_LIGIER_PORT)s -p %(ENV_DAQ_LIGIER_PORT)s %(ENV_DAQ_LIGIER_IP)s
priority=10
stdout_logfile=logs/%(program_name)s.out.log        ; stdout log path, NONE for none; default AUTO
stderr_logfile=logs/%(program_name)s.err.log        ; stderr log path, NONE for none; default AUTO

[program:ahrs_calibration]
command=python -u scripts/ahrs_calibration.py -d %(ENV_DETECTOR_ID)s -p %(ENV_MONITORING_LIGIER_PORT)s
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;priority=999                  ; the relative start priority (default 999)
;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)
;startretries=3                ; max # of serial start failures when starting (default 3)
;autorestart=unexpected        ; when to restart if exited after running (def: unexpected)
;redirect_stderr=true          ; redirect proc stderr to stdout (default false)
stdout_logfile=logs/%(program_name)s.out.log        ; stdout log path, NONE for none; default AUTO
stderr_logfile=logs/%(program_name)s.err.log        ; stderr log path, NONE for none; default AUTO

[program:dom_activity]
command=python -u scripts/dom_activity.py -d %(ENV_DETECTOR_ID)s -p %(ENV_MONITORING_LIGIER_PORT)s
stdout_logfile=logs/%(program_name)s.out.log
stderr_logfile=logs/%(program_name)s.err.log

[program:dom_rates]
command=python -u scripts/dom_rates.py -d %(ENV_DETECTOR_ID)s -p %(ENV_MONITORING_LIGIER_PORT)s
stdout_logfile=logs/%(program_name)s.out.log
stderr_logfile=logs/%(program_name)s.err.log

[program:pmt_rates]
command=python -u scripts/pmt_rates.py -d %(ENV_DETECTOR_ID)s -p %(ENV_MONITORING_LIGIER_PORT)s -i 20 -u 3
stdout_logfile=logs/%(program_name)s.out.log
stderr_logfile=logs/%(program_name)s.err.log

[program:pmt_hrv]
command=python -u scripts/pmt_hrv.py -d %(ENV_DETECTOR_ID)s -p %(ENV_MONITORING_LIGIER_PORT)s -i 20 -u 3
stdout_logfile=logs/%(program_name)s.out.log
stderr_logfile=logs/%(program_name)s.err.log

[program:trigger_rates]
command=python -u scripts/trigger_rates.py -p %(ENV_MONITORING_LIGIER_PORT)s
stdout_logfile=logs/%(program_name)s.out.log
stderr_logfile=logs/%(program_name)s.err.log
 
[program:triggermap]
command=python -u scripts/live_triggermap.py -d %(ENV_DETECTOR_ID)s -p %(ENV_MONITORING_LIGIER_PORT)s
stdout_logfile=logs/%(program_name)s.out.log
stderr_logfile=logs/%(program_name)s.err.log

[program:ztplot]
command=python -u scripts/ztplot.py -d %(ENV_DETECTOR_ID)s -p %(ENV_MONITORING_LIGIER_PORT)s
stdout_logfile=logs/%(program_name)s.out.log
stderr_logfile=logs/%(program_name)s.err.log

[program:royfit]
command=julia scripts/live_royfit.jl %(ENV_DETX)s %(ENV_MONITORING_LIGIER_PORT)s %(ENV_ROYFIT_TIMERES)s
stdout_logfile=logs/%(program_name)s.out.log
stderr_logfile=logs/%(program_name)s.err.log

[program:time_residuals]
command=python -u scripts/time_residuals.py %(ENV_ROYFIT_TIMERES)s
stdout_logfile=logs/%(program_name)s.out.log
stderr_logfile=logs/%(program_name)s.err.log

[program:rttc]
command=python -u scripts/rttc.py -d %(ENV_DETECTOR_ID)s -l %(ENV_DETECTOR_MANAGER_IP)s
stdout_logfile=logs/%(program_name)s.out.log
stderr_logfile=logs/%(program_name)s.err.log

;[program:k40]
;command=python -u scripts/k40_calibration.py -d %(ENV_DETECTOR_ID)s -p %(ENV_MONITORING_LIGIER_PORT)s
;stdout_logfile=logs/%(program_name)s.out.log
;stderr_logfile=logs/%(program_name)s.err.log

[program:msg_dumper]
command=python -u scripts/msg_dumper.py -l %(ENV_LOG_LIGIER_IP)s -p %(ENV_LOG_LIGIER_PORT)s -f logs/MSG.log
priority=200
stdout_logfile=logs/%(program_name)s.out.log
stderr_logfile=logs/%(program_name)s.err.log

[program:weblog]
command=%(ENV_HOME)s/bin/frontail logs/MSG.log --ui-highlight --ui-highlight-preset frontail.json --theme dark -l 10000 -n 200 -p %(ENV_LOGGING_PORT)s
priority=210
stdout_logfile=logs/%(program_name)s.out.log
stderr_logfile=logs/%(program_name)s.err.log


[group:ligiers]
programs=monitoring_ligier,ligiermirror
priority=1

[group:logging]
programs=weblog,msg_dumper
priority=200

[group:monitoring_process]
programs=ahrs_calibration,dom_activity,dom_rates,pmt_rates,pmt_hrv,trigger_rates,triggermap,ztplot,rttc
priority=500

[group:reconstruction]
programs=royfit,time_residuals
priority=999

;[group:calibration]
;programs=k40
;priority=999

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.

;[include]
;files = relative/directory/*.ini
