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

Conversation

mogsie
Copy link
Member

@mogsie mogsie commented Jan 25, 2019

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.

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.
@mogsie mogsie requested review from skybert and mhersson January 25, 2019 13:27
# 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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants