This repository has been archived by the owner on Aug 20, 2019. It is now read-only.
forked from jacone/ece-scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
Added escenic-jstat systemd service #72
Open
mogsie
wants to merge
1
commit into
release/4.0
Choose a base branch
from
feature/jstat-systemd
base: release/4.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
|
||
# 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 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both
su -c
andsudo
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 thegosu
completely.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is not an option?