Skip to content
This repository has been archived by the owner on Aug 20, 2019. It is now read-only.

Added escenic-jstat systemd service #72

Open
wants to merge 1 commit into
base: release/4.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/systemd/system/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Unit]
Description=Jstat process for %i

[Service]

# 1. Check if the pidfile is a valid pid file, if not, do nothing.
# 2. redirect output to a log-file (exec 2>&1), truncate it.
# 3. Become the user that owns the pidfile (gosu)
# 4. chain (exec) to the jstat process so that systemd can kill jstat
# jstat will quit when the process in pidfile quits
ExecStart=/bin/bash -c 'if pgrep &> /dev/null --pidfile /var/run/escenic/%i.pid; then echo found pid; exec 2>&1 > /var/log/escenic/%i-jstat.log; date --utc --iso=seconds; exec gosu $(stat -c %%U /var/run/escenic/%i.pid) jstat -gcutil $(cat /var/run/escenic/%i.pid) 1000; fi'
Copy link

@skybert skybert Jan 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gosu isn't installed by default on Ubuntu 18.04 and Debian 9 and isn't available in the default repositories in CentOS 7.

How about using su -c?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both su -c and sudo are resident, and don't forward signals, meaning that they introduce a (bad) layer of insulation between systemd and jstatd. It might be possible to hard-code this service as the escenic used, though, and remove the gosu completely.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Service]
User=escenic
Group=escenic

is not an option?


# This service quits when the process being monitored dies, and then
# it is respawned continuously until the pidfile lists a pid that can
# be monitored again.
Restart=always
RestartSec=12

[Install]
WantedBy=multi-user.target