Skip to content

Commit

Permalink
Add systemd user service...
Browse files Browse the repository at this point in the history
Same systemd service unit file was being used for system and user which works fine for
system service but for user service it causes a problem when a user enables the
unit. As install target is set to `multi-user.target` which doesn't
exist for user, it prints a warning and doesn't function as expected.

So instead create seperate user service unit, which changes its
install target to `default.target`.

Signed-off-by: Rahil Bhimjiani <[email protected]>
  • Loading branch information
rahilarious committed Mar 16, 2024
1 parent 4ef50ed commit 66be30e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions contrib/systemd/user/prometheus-podman-exporter.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Prometheus exporter for podman (v4) machine
[Service]
Restart=on-failure
EnvironmentFile=-/etc/sysconfig/prometheus-podman-exporter
ExecStart=/usr/bin/prometheus-podman-exporter $PODMAN_EXPORTER_OPTS
ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=20s
SendSIGKILL=no
[Install]
WantedBy=default.target
2 changes: 1 addition & 1 deletion prometheus-podman-exporter.spec.rpkg
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ install -dp %{buildroot}%{_userunitdir}
install -p ./bin/%{name} %{buildroot}%{_bindir}
install -Dpm0644 ./contrib/systemd/%{name}.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/%{name}
install -Dpm0644 ./contrib/systemd/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
install -Dpm0644 ./contrib/systemd/%{name}.service %{buildroot}%{_userunitdir}/%{name}.service
install -Dpm0644 ./contrib/systemd/user/%{name}.service %{buildroot}%{_userunitdir}/%{name}.service

pushd %{buildroot}%{_unitdir}
ln -s %{name}.service %{shortname}.service
Expand Down

0 comments on commit 66be30e

Please sign in to comment.