With default settings, ZNC will shut down with SIGTERM, leading to ghost sessions on IRC network and possible nick collisions when reconnecting right afterwards.
znc.service is easy enough, but znc.conf is generated so I'm not sure how to change it there, else I'd have made a pull request myself already.
With default settings, ZNC will shut down with SIGTERM, leading to ghost sessions on IRC network and possible nick collisions when reconnecting right afterwards.
I think this is unnecessary since ZNC already supports a method of shutting down in a controlled manner - SIGINT. Man page says:
https://github.com/znc/znc/blob/master/man/znc.1
>.B SIGINT
>Exit ZNC. This is equivalent to
>.I /znc shutdown
This should be the default in my opinion, I configured it like this myself and now ZNC shuts down cleanly.
It needs two config file changes:
1) znc.service
add this line:
>ExecStop=/usr/bin/pkill -INT -F /var/lib/znc/.znc/znc.pid
2) znc.conf
add this line:
>PidFile = /var/lib/znc/.znc/znc.pid
znc.service is easy enough, but znc.conf is generated so I'm not sure how to change it there, else I'd have made a pull request myself already.
<!-- github-sync-id:290447883 -->
man systemd.service says that sending a signal from ExecStop is not okay:
Note that it is usually not sufficient to specify a command for this setting that only asks the service to terminate (for example, by queuing some form of termination signal for it), but does not wait for it to do so. Since the remaining processes of the services are killed according to KillMode= and KillSignal= as described above immediately after the command exited, this may not result in a clean stop. The specified command should hence be a synchronous operation, not an asynchronous one.
According to man systemd.kill, the default value for KillSignal is SIGTERM, which is a signal that ZNC should handle by shutting down cleanly. So perhaps you should investigate why this does not work for you.. Anything in the logs / journal? According to this man page, systems sends a SIGTERM, then waits 90 seconds (default value for TimeoutStopSec), then sends a SIGKILL.
`man systemd.service` says that sending a signal from `ExecStop` is not okay:
Note that it is usually not sufficient to specify a command for this setting that only asks the service to terminate (for example, by queuing some form of termination signal for it), but does not wait for it to do so. Since the remaining processes of the services are killed according to KillMode= and KillSignal= as described above immediately after the command exited, this may not result in a clean stop. The specified command should hence be a synchronous operation, not an asynchronous one.
-----
According to `man systemd.kill`, the default value for `KillSignal` is `SIGTERM`, which is a signal that ZNC should handle by shutting down cleanly. So perhaps you should investigate why this does not work for you.. Anything in the logs / journal? According to this man page, systems sends a `SIGTERM`, then waits 90 seconds (default value for `TimeoutStopSec`), then sends a `SIGKILL`.
<!-- github-comment-id:359426233 -->
I don't remember ZNC ever shutting down properly when being terminated by systemd, and by that I mean log itself out from all IRC networks. I always had to do "/znc ShutDown" or there were ghost sessions.
I don't remember ZNC ever shutting down properly when being terminated by systemd, and by that I mean log itself out from all IRC networks. I always had to do "/znc ShutDown" or there were ghost sessions.
<!-- github-comment-id:359427883 -->
Jän 22 15:08:02 localhost znc[28830]: Exiting on SIG [15]
Fixed by commit 0750e529c5 from 2015 which removed the code that printed this and also (unintentionally?) changed the exit code from the signal number to 0.
However, the same should happen with your previous solution of sending SIGINT....?
> Jän 22 15:08:02 localhost znc[28830]: Exiting on SIG [15]
Fixed by commit 0750e529c5327c94bddf1a4d20c415efbe9bc4e4 from 2015 which removed the code that printed this and also (unintentionally?) changed the exit code from the signal number to 0.
However, the same should happen with your previous solution of sending SIGINT....?
<!-- github-comment-id:359445031 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
With default settings, ZNC will shut down with SIGTERM, leading to ghost sessions on IRC network and possible nick collisions when reconnecting right afterwards.
I think this is unnecessary since ZNC already supports a method of shutting down in a controlled manner - SIGINT. Man page says:
https://github.com/znc/znc/blob/master/man/znc.1
This should be the default in my opinion, I configured it like this myself and now ZNC shuts down cleanly.
It needs two config file changes:
add this line:
add this line:
znc.service is easy enough, but znc.conf is generated so I'm not sure how to change it there, else I'd have made a pull request myself already.
man systemd.servicesays that sending a signal fromExecStopis not okay:Note that it is usually not sufficient to specify a command for this setting that only asks the service to terminate (for example, by queuing some form of termination signal for it), but does not wait for it to do so. Since the remaining processes of the services are killed according to KillMode= and KillSignal= as described above immediately after the command exited, this may not result in a clean stop. The specified command should hence be a synchronous operation, not an asynchronous one.
According to
man systemd.kill, the default value forKillSignalisSIGTERM, which is a signal that ZNC should handle by shutting down cleanly. So perhaps you should investigate why this does not work for you.. Anything in the logs / journal? According to this man page, systems sends aSIGTERM, then waits 90 seconds (default value forTimeoutStopSec), then sends aSIGKILL.I don't remember ZNC ever shutting down properly when being terminated by systemd, and by that I mean log itself out from all IRC networks. I always had to do "/znc ShutDown" or there were ghost sessions.
I tried setting everything to defaults now, and it seems to work.
However, "systemctl status znc" reports
Jän 22 15:08:02 localhost systemd[1]: Stopping ZNC, an advanced IRC bouncer...
Jän 22 15:08:02 localhost znc[28830]: Exiting on SIG [15]
Jän 22 15:08:02 localhost systemd[1]: znc.service: Main process exited, code=exited, status=15/n/a
Jän 22 15:08:02 localhost systemd[1]: Stopped ZNC, an advanced IRC bouncer.
Jän 22 15:08:02 localhost systemd[1]: znc.service: Unit entered failed state.
Jän 22 15:08:02 localhost systemd[1]: znc.service: Failed with result 'exit-code'.
Fixed by commit
0750e529c5from 2015 which removed the code that printed this and also (unintentionally?) changed the exit code from the signal number to 0.However, the same should happen with your previous solution of sending SIGINT....?
I think it did, but I'm using znc 1.6.4 from December 2016, so why does it still show exit code 15?
That commit is in no znc release yet. 1.6.4 was released from a branch.
I see, so 1.7.0 probably?
yep