概要: 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 自訂的重啟設定將不會應用到這些服務。