coreos-home-server/config/service/nginx/systemd/nginx-serve-static@.service
Alex Palaistras a4580e1cae Improve service initialization, move system files
System files are moved to `/etc/coreos-home-server` to be unambiguous
in relation to other, pre-installed system files. Long-running services
are also now defined as `Type=notify`, which helps improve ordering and
dependencies.
2021-08-14 22:28:28 +01:00

26 lines
1.0 KiB
Desktop File

[Unit]
Description=NGINX static web service for %I
Wants=container-build@%i.service nginx.service nginx-proxy-http@%i.service
After=container-build@%i.service nginx.service
Before=nginx-proxy-http@%i.service
[Service]
Type=notify
NotifyAccess=all
Restart=on-failure
Environment=PODMAN_SYSTEMD_UNIT=%n
Environment=SERVER_NAME=%i SERVICE_DATA_DIRECTORY=/data
Environment=NGINX_CONF=%E/coreos-home-server/nginx/service/%p.conf.template
ExecStartPre=/bin/podman create --replace --pull never --name %i --net internal --sdnotify=conmon \
--volume %i:${SERVICE_DATA_DIRECTORY}:z,ro \
localhost/%i:latest
ExecStartPre=/bin/sh -c "envsubst '$SERVER_NAME' < ${NGINX_CONF} > /tmp/%i.conf"
ExecStartPre=/bin/sh -c 'podman cp /tmp/%i.conf %i:/etc/nginx/conf.d/%i.conf && rm -f /tmp/%i.conf'
ExecStart=/bin/podman start --attach %i
ExecStop=/bin/podman stop --ignore --time 10 %i
ExecStopPost=/bin/podman rm --ignore --force %i
[Install]
Alias=%i.service
WantedBy=multi-user.target