[Unit]
Description=Nomad JWKS proxy
After=syslog.target network-online.target remote-fs.target nss-lookup.target nomad.service
Wants=network-online.target

[Service]
Type=simple
User={{ nomad_user }}
Group={{ nomad_user }}
PIDFile=/run/nomad/nomad-jwks-proxy.pid
ExecStartPre=/sbin/nginx -t -c {{ nomad_root_dir }}/jwks-proxy/nginx.conf -e /dev/null
ExecStartPre=/bin/rm -f /run/nomad/nomad-jwks-proxy.pid
ExecStart=/sbin/nginx -c {{ nomad_root_dir }}/jwks-proxy/nginx.conf -g "daemon off;" -e /dev/null
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
Restart=on-failure
StartLimitInterval=0
RestartSec=5

[Install]
WantedBy=multi-user.target
