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

Prolong wait time for shutdown #15414

Merged
merged 1 commit into from
Sep 4, 2021
Merged

Prolong wait time for shutdown #15414

merged 1 commit into from
Sep 4, 2021

Conversation

Chocobo1
Copy link
Member

@Chocobo1 Chocobo1 commented Sep 3, 2021

The default was 90s, prolong to 30 mins.
From the discussion in #15381 (comment), ~2k torrents took 5 mins to completely shutdown. Here we wait at most 30 mins which scales to about 12k torrents which should cover most use case (also note that 4.3.x series is mentioned to have even shorter shutdown time).

Setting it to infinity isn't a good idea since that would potentially stall the system if anything go wrong.

The default was 90s[1], prolong to 30 mins.
From the discussion in [2], ~2k torrents took 5 mins to completely
shutdown. Here we wait at most 30 mins which scales to about 12k
torrents which should cover most use case (also note that 4.3.x series
is mentioned to have even shorter shutdown time).

[1] https://www.freedesktop.org/software/systemd/man/systemd-system.conf.html#DefaultTimeoutStartSec=
[2] qbittorrent#15381 (comment)
@Chocobo1 Chocobo1 added the OS: Linux Issues specific to Linux distributions label Sep 3, 2021
@Chocobo1 Chocobo1 added this to the 4.4.0 milestone Sep 3, 2021
@Chocobo1 Chocobo1 requested a review from a team September 3, 2021 03:43
@ArcticGems

This comment has been minimized.

@Chocobo1
Copy link
Member Author

Chocobo1 commented Sep 3, 2021

Is it possible to scale/adapt the "wait time for shutdown" according to how many active torrents you have at the moment you click to exit???

It isn't necessary.
You misunderstood the concept. Systemd will actually monitor qbt-nox and react asap when the process has exited. The 30mins setting only applies to the time limit of systemd monitor before it hard kills qbt-nox. In other words, no additional waiting time is implied, the shutdown time is still as fast as usual.

@Kolcha
Copy link
Contributor

Kolcha commented Sep 3, 2021

according to https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStop= (the second paragraph)
setting timeout may be not enough, and that was true at least in my case - after sending SIGTERM signal it didn't wait for qbittorrent exit, so that's why mentioned script used as ExecStop command is appeared. I didn't tried to disable it for very long time just because it just works, so don't know is it necessary nowadays.

very likely something like my simple script can be embedded into systemd unit as one-line script for mentioned ExecStop, but again I didn't tried to do that because everything just works fine in my environment and there is no reason to change something.

moreover, I have some ExecStartPre and ExecStartPost scripts, so having ExecStop script just looks symmetric :)

this is just for information

@Chocobo1
Copy link
Member Author

Chocobo1 commented Sep 4, 2021

according to https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStop= (the second paragraph)
setting timeout may be not enough, and that was true at least in my case - after sending SIGTERM signal it didn't wait for qbittorrent exit, so that's why mentioned script used as ExecStop command is appeared. I didn't tried to disable it for very long time just because it just works, so don't know is it necessary nowadays.

I tested this PR and it works as described. I made qbt continue to run when receiving SIGTERM signal and observe the waiting time of systemctl stop [email protected]. It correlates with TimeoutStopSec= correctly.

Also note https://www.freedesktop.org/software/systemd/man/systemd.kill.html#KillMode=
I believe it describes the behavior I saw in my testing.

Processes will first be terminated via SIGTERM ... If processes still remain after the main process of a unit has exited or the delay configured via the TimeoutStopSec= has passed, the termination request is repeated with the SIGKILL signal or the signal specified via FinalKillSignal= ...

@Chocobo1 Chocobo1 merged commit 615b76f into qbittorrent:master Sep 4, 2021
@Chocobo1 Chocobo1 deleted the exit branch September 4, 2021 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS: Linux Issues specific to Linux distributions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants