systemd:设置 openvpn-client@服务 TimeoutStopUSec?

systemd:设置 openvpn-client@服务 TimeoutStopUSec?

我在 ubuntu 18.04 上设置了一个 openvpn 客户端,创建了/etc/openvpn/client/foo.conf

每当我停止服务时,

sudo systemctl stop [email protected]

它挂起了 90 秒,并且日志显示正常终止超时:

Stopping OpenVPN tunnel for foo...
[email protected]: State 'stop-sigterm' timed out. Killing.
[email protected]: Killing process 12737 (openvpn) with signal SIGKILL.
[email protected]: Main process exited, code=killed, status=9/KILL
[email protected]: Failed with result 'timeout'.
Stopped OpenVPN tunnel for foo.

我仍在尝试找出根本问题,但同时我想减少TimeoutStopUSec这项服务的设置。

systemctl show [email protected] -p TimeoutStopUSec
TimeoutStopUSec=1min 30s

如果这是我为其创建单元文件的单元,我会知道该怎么做,但是我该如何为 ubuntu 自动生成的服务执行此操作?

答案1

我似乎找到了解决办法。

sudo systemctl edit [email protected]

添加以下内容:

[Service]
TimeoutStopSec=30s

重新加载配置并重启服务

sudo systemctl daemon-reload
sudo systemctl restart [email protected]

相关内容