darold / sendmailanalyzer

Sendmail log Analyzer is a tool to monitor sendmail usage and generate HTML and graph reports. It reports all you ever wanted to know about email trafic on your network. You can also use it in ISP environment with per domain and per mailbox report.
http://sendmailanalyzer.darold.net/
GNU General Public License v3.0
76 stars 13 forks source link

Wrong script for systemd startup #18

Closed fmalfatto closed 10 years ago

fmalfatto commented 10 years ago

I'm not able to stop sendmailanalyzer via "systemctl stop sendmailanalyzer.service" under opensuse 12.3.

The service definition has the following line: ExecStop=/bin/kill -TERM sendmailanalyzer

But kill needs the process id, not the process name.

I tried to change that line to ExecStop=/bin/kill -TERM $MAINPID as from systemd docs, but it does not work.

That bug make me unable to have senmailanalyze restarted after syslog rotation, and it fails every night.

darold commented 10 years ago

You can use pkill instead of kill like follow if you have such utility installed:

ExecStop=/usr/bin/pkill -TERM sendmailanalyzer

or use the pid file instead:

ExecStop=/bin/kill -TERM  `cat /var/run/sendmailanalyzer.pid`

or something like that. The path of the pid file is defined into sendmailanalyzer.conf with directive PID_DIR.

Or better is to restart sendmailanalyzer directly from syslog rotation. In my /etc/logrotate.d/rsyslog I have the following in the postrotate part:

        postrotate
            reload rsyslog >/dev/null 2>&1 || true
            /bin/kill -HUP `cat /var/run/sendmailanalyzer.pid`  2>/dev/null || true
        endscript

Let me know what's solves your issue.

fmalfatto commented 10 years ago

Having pkill installed, in sendmailanalyzer.service I changed to ExecStop=/usr/bin/pkill -TERM sendmailanalyzer

and in /etc/logrotate.d/syslog I added in postrotate: /usr/bin/systemctl restart sendmailanalyzer.service > /dev/null 2>&1 || true

All is working perfectly now! Ty very much for fast and clean help!

darold commented 10 years ago

Ok, I will drop a line about that in documentation

fmalfatto commented 8 years ago

Small correction: the reported line in sendmailanalyzer.service ExecStop=/bin/kill -TERM cat /var/run/sendmailanalyzer.pid does not work in OpenSuse 13.1, reporting "No such process" .

The correct line would be: ExecStop=/bin/bash -c "/bin/kill -TERM /usr/bin/cat /var/run/sendmailanalyzer.pid"

darold commented 8 years ago

Thanks for the report, latest commit be3083f adds your patch.

Best regards,