Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reloading Telegraf under systemd #1279

Merged
merged 1 commit into from
May 26, 2016
Merged

Conversation

PierreF
Copy link
Contributor

@PierreF PierreF commented May 26, 2016

Required for all PRs:

  • CHANGELOG.md updated
  • Sign CLA (if not already signed)

PR #1252 works well for stopping Telegraf, but reloading cause Telegraf to exit:

$ dpkg -l telegraf 
ii  telegraf       0.13.1~a8334c3-0
$ ps waux|grep telegraf
telegraf 13662  0.0  0.0   4508   756 ?        Ss   11:31   0:00 /bin/sh -c /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d  >>/var/log/telegraf/telegraf.log 2>>/var/log/telegraf/telegraf.log
telegraf 13663  0.3  0.2 227988 23380 ?        Sl   11:31   0:00 /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d
$ sudo systemctl reload telegraf
$ sudo systemctl status telegraf
[...]
   Active: inactive (dead) since jeu. 2016-05-26 11:33:08 CEST; 3s ago
[...]
 Main PID: 13662 (code=killed, signal=HUP)
$ ps waux|grep telegraf
nothing

This is caused since $MAINPID (used by ExecReload=/bin/kill -HUP $MAINPID) is the sh process. When sh process get a SIGHUP, it exits which cause child process (Telegraf) to be killed.

This PR add an "exec" which cause sh processed to be replaced by Telegraf, thus $MAINPID is now Telegraf itself.

$ dpkg -l telegraf 
ii  telegraf       0.13.1~46f0196-0
$ ps waux|grep telegraf
telegraf 15816  1.0  0.2 301976 23756 ?        Ssl  11:37   0:00 /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d
$ sudo systemctl reload telegraf
$ sudo systemctl status telegraf
[...]
   Active: active (running) since jeu. 2016-05-26 11:37:04 CEST; 35s ago
[...]
 Main PID: 15816 (telegraf)
$ ps waux|grep telegraf
telegraf 15816  0.5  0.3 460808 30972 ?        Ssl  11:37   0:00 /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d

Logs continue to be written to /var/log/telegraf/telegraf.log

@sparrc
Copy link
Contributor

sparrc commented May 26, 2016

thanks @PierreF

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

Successfully merging this pull request may close these issues.

2 participants