KillSignal在systemd中如何与TimeoutStopSec交互?

3

有人能告诉我关于systemd服务关闭顺序的以下内容吗?

  1. 如果我指定了 KillSignal=SIGTERM,那么它如何与 TimeoutStopSec 交互?这是否意味着在服务关闭期间,首先会发送 SIGTERM,如果服务在 TimeoutStopSec 后仍在运行,则会发送 SIGKILL(如果将 SendSIGKILL 设置为 yes)? 我是问在 ExecStop 中未指定任何内容的情况下。

  2. TimeoutStopSec 是否考虑了 ExecStop 和所有的 ExecPostStop

2个回答

3

这个问题在systemd邮件线程中已经得到解答。以下是回答:

Can someone let me know the following about systemd service shutdown sequence

1.

If I have specified KillSignal=SIGTERM then how does this interact this
TimeoutStopSec ? Does this mean that during shutdown of service, first
SIGTERM will be sent and if the service is still running after
TimeoutStopSec SIGKILL will be sent (if SendSIGKILL is set to yes? I am
asking about the case where nothing is specified in ExecStop.

Yes, that's correct

2.

Does TimeoutStopSec take into account ExecStop and all ExecPostStop?

TimeoutStopSec is for every command. If ExecStopPost command fails (or times out) subsequent commands are not executed, but if each command requires almost TimeoutStopSec time, total execution time will be close to ExecStopPost commands multiplied by TimeoutStopSec.


0

从那个systemd man

此选项有两个目的。首先,它配置了每个ExecStop=命令的等待时间。如果其中任何一个超时,后续的ExecStop=命令将被跳过,并且服务将通过SIGTERM终止。如果没有指定ExecStop=命令,则服务会立即收到SIGTERM。这种默认行为可以通过TimeoutStopFailureMode=选项进行更改。其次,它配置了等待服务本身停止的时间。如果在指定的时间内未终止,将通过SIGKILL强制终止(请参阅systemd.kill(5)中的KillMode=)。以无单位的秒值或时间跨度值(例如"5min 20s")传递。传递"infinity"以禁用超时逻辑。默认为管理器配置文件中的DefaultTimeoutStopSec=(请参阅systemd-system.conf(5))。
如果Type=notify的服务发送"EXTEND_TIMEOUT_USEC=…",这可能导致停止时间超过TimeoutStopSec=。必须在TimeoutStopSec=超过之前首次接收到此消息,并且一旦停止时间超过TimeoutStopSec=,服务管理器将允许服务继续停止,前提是服务在指定的间隔内重复发送"EXTEND_TIMEOUT_USEC=…",或者自行终止(请参阅sd_notify(3))。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接