[supervisord]
pidfile = {{ config.pid_file }}
directory = {{ config.workdir }}
nodaemon = true

{# disable initial logging until patch_logger.py takes over #}
logfile = /dev/null
logfile_maxbytes = 0
silent = true

{# config for patch_logger.py #}
loglevel = {{ config.loglevel }}
{# there are more options in the plugin section #}

[unix_http_server]
file = {{ config.unix_http_server }}

[supervisorctl]
serverurl = unix://{{ config.unix_http_server }}

{# Extensions to changing the supervisord behavior #}
[rpcinterface:patch_logger]
supervisor.rpcinterface_factory = knot_resolver.controller.supervisord.plugin.patch_logger:inject
target = {{ config.target }}

[rpcinterface:manager_integration]
supervisor.rpcinterface_factory = knot_resolver.controller.supervisord.plugin.manager_integration:inject

{# sd_notify is supported only on Linux based systems #}
{% if config.notify_support -%}
[rpcinterface:sd_notify]
supervisor.rpcinterface_factory = knot_resolver.controller.supervisord.plugin.sd_notify:inject
{%- endif %}

{# Extensions for actual API control #}
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[rpcinterface:fast]
supervisor.rpcinterface_factory = knot_resolver.controller.supervisord.plugin.fast_rpcinterface:make_main_rpcinterface

[program:manager]
redirect_stderr=false
directory={{ manager.workdir }}
command={{ manager.command }}
stopsignal=SIGINT
killasgroup=true
autorestart=true
autostart=true
{# Note that during startup,
   manager will signal being ready only after sequential startup of all kresd workers,
   i.e. it might take lots of time currently, if the user configured very large rulesets (e.g. huge RPZ).
   Let's permit it lots of time, assuming that useful work is being done.
#}
startsecs={{ manager.startsecs }}
environment={{ manager.environment }}
stdout_logfile=NONE
stderr_logfile=NONE

[program:kresd]
process_name=%(program_name)s%(process_num)d
numprocs={{ kresd.max_procs }}
directory={{ kresd.workdir }}
command={{ kresd.command }}
autostart=false
autorestart=true
stopsignal=TERM
killasgroup=true
startsecs={{ kresd.startsecs }}
environment={{ kresd.environment }}
stdout_logfile=NONE
stderr_logfile=NONE

[program:policy-loader]
directory={{ loader.workdir }}
command={{ loader.command }}
autostart=false
stopsignal=TERM
killasgroup=true
exitcodes=0
startsecs={{ loader.startsecs }}
environment={{ loader.environment }}
stdout_logfile=NONE
stderr_logfile=NONE

[program:cache-gc]
redirect_stderr=false
directory={{ gc.workdir }}
command={{ gc.command }}
autostart=false
autorestart=true
stopsignal=TERM
killasgroup=true
startsecs={{ gc.startsecs }}
environment={{ gc.environment }}
stdout_logfile=NONE
stderr_logfile=NONE
