概要: On Linux distributions that use the systemd init system (Debian 8 and later, CentOS/RedHat 7 and later, and Ubuntu 18 and later), Plesk instructs systemd to restart certain services if they crash.

In this topic, you will learn how to customize the automatic restart of the crashed services.

The following services are automatically restarted via systemd:

  • Plesk 服务 (sw-cp-server、sw-engine)
  • 主机服务 (PHP-FMP、nginx)
  • 某些其它服务 (Dovecot、MariaDB,等等)

systemd 重启有以下设置,您可以通过 panel.ini 文件进行自定义:

  • respawn 设置会控制是否自动重启缓存的服务。会默认启用该设置。若要将其关闭,请将 respawn 设置值更改为 off

  • Service.RestartSec 设置会指定 systemd 重启缓存服务后的宕机时间(默认为 5 秒)。

  • Service.Restart 设置会指定必须重启服务的条件。该设置的默认值是 on-failure。表示在退出出现非零退出代码时将重启服务。

    Service.Restart 设置会接受以下值:no|always|on-success|on-failure|on-abnormal|on-abort|on-watchdog. 查看这些值的含义

若要自定义使用 systemd 自动重启缓存服务,请如下操作:

  1. 将您想要更改的 systemd 设置添加到 panel.ini 文件(在 [systemd] 部分下)。例如:

    [systemd]
    Service.RestartSec = 7
    Service.Restart = always
    
  2. 自定义设置要生效,需运行以下模式的命令:

    /usr/local/psa/admin/sbin/register_service --enable <service>
    

    其中 <service>此列表中的任何服务

    例如:

    /usr/local/psa/admin/sbin/register_service --enable sw-engine
    

然后自定义设置将被应用。

注解: 某些服务(例如,Fail2Ban、PostgreSQL 以及其它)有其自己的 systemd 重启设置,可能会与默认的有所不同。通过 panel.ini 自定义的重启设置将不会应用到这些服务。