This repository was archived by the owner on Aug 20, 2019. It is now read-only.
Open
Conversation
To enable, for any java process that writes its pid to a pidfile in /var/run/escenic, for example 'engine1.pid': systemctl enable escenic-jstat@engine1 systemctl start escenic-jstat@engine1 Then after a few seconds, you will see in /var/log/escenic/engine1-jstat.log: 2019-01-25T12:58:25+00:00 S0 S1 E O M CCS YGC YGCT FGC FGCT GCT 10.55 0.00 41.13 27.62 97.09 94.06 4382 169.803 6 0.218 170.021 10.55 0.00 41.14 27.62 97.09 94.06 4382 169.803 6 0.218 170.021 10.55 0.00 41.14 27.62 97.09 94.06 4382 169.803 6 0.218 170.021 Whenever engine1 is restarted, this logfile will be truncated, with no rotation.
skybert
suggested changes
Jan 25, 2019
| # 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' |
There was a problem hiding this comment.
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?
Member
Author
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
[Service]
User=escenic
Group=escenic
is not an option?
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
To enable, for any java process that writes its pid to a pidfile in
/var/run/escenic, for example 'engine1.pid':
systemctl enable escenic-jstat@engine1
systemctl start escenic-jstat@engine1
Then after a few seconds, you will see in
/var/log/escenic/engine1-jstat.log:
Whenever engine1 is restarted, this logfile will be truncated, with no rotation.