mirror of
https://github.com/deuill/coreos-home-server.git
synced 2024-09-21 21:50:46 +00:00
20 lines
780 B
SYSTEMD
20 lines
780 B
SYSTEMD
|
[Unit]
|
||
|
Description=Register Prometheus Metrics for %I
|
||
|
Wants=prometheus.service
|
||
|
After=prometheus.service
|
||
|
|
||
|
[Service]
|
||
|
Type=oneshot
|
||
|
RemainAfterExit=true
|
||
|
SyslogIdentifier=%N
|
||
|
Environment=SERVICE_HOST=%i
|
||
|
Environment=PROMETHEUS_CONF=%E/coreos-home-server/prometheus/service/%p.yml.template
|
||
|
ExecStart=/bin/sh -c "envsubst '$SERVICE_HOST' < ${PROMETHEUS_CONF} > /tmp/%i.yml"
|
||
|
ExecStartPost=/bin/sh -c 'podman cp --archive=false /tmp/%i.yml prometheus:/etc/prometheus/service.d/%i.yml && rm -f /tmp/%i.yml'
|
||
|
ExecStartPost=/bin/podman exec prometheus sh -c 'kill -HUP $(pidof prometheus)'
|
||
|
ExecStop=/bin/podman exec --user=root prometheus rm -f /etc/prometheus/service.d/%i.yml
|
||
|
ExecStopPost=/bin/podman exec prometheus sh -c 'kill -HUP $(pidof prometheus)'
|
||
|
|
||
|
[Install]
|
||
|
WantedBy=multi-user.target
|