Centos
以 root 以外的系統使用者身份在 CentOS 上執行服務
我已經創建了一個系統使用者
jackett
(useradd -r jackett
) 並且我試圖在 CentOS 7 上執行一個 systemd 服務。服務文件:
[Unit] Description=Jackett Daemon After=network-online.target [Service] Type=simple user=jackett group=jackett ExecStart=/usr/bin/mono --debug /opt/Jackett/JackettConsole.exe --NoRestart [Install] WantedBy=multi-user.target
服務狀態:
[root@server Jackett]# systemctl status jackett ● jackett.service - Jackett Daemon Loaded: loaded (/usr/lib/systemd/system/jackett.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2019-02-23 23:42:23 +03; 11min ago Main PID: 24735 (mono) CGroup: /system.slice/jackett.service └─24735 /usr/bin/mono --debug /opt/Jackett/JackettConsole.exe --NoRestart Feb 23 23:42:24 server mono[24735]: 02-23 23:42:24 Info Loading Cardigann definition /opt/Jackett/Definitions/yourexotic.yml Feb 23 23:42:24 server mono[24735]: 02-23 23:42:24 Info Loading Cardigann definition /opt/Jackett/Definitions/zamundanet.yml Feb 23 23:42:24 server mono[24735]: 02-23 23:42:24 Info Loading Cardigann definition /opt/Jackett/Definitions/zelkaorg.yml Feb 23 23:42:24 server mono[24735]: 02-23 23:42:24 Info Loading Cardigann definition /opt/Jackett/Definitions/zooqle.yml Feb 23 23:42:24 server mono[24735]: 02-23 23:42:24 Info Loading Cardigann definition /opt/Jackett/Definitions/ztracker.yml Feb 23 23:42:24 server mono[24735]: 02-23 23:42:24 Info Adding aggregate indexer Feb 23 23:42:25 server mono[24735]: Hosting environment: Production Feb 23 23:42:25 server mono[24735]: Content root path: /opt/Jackett/Content Feb 23 23:42:25 server mono[24735]: Now listening on: http://[::]:9117 Feb 23 23:42:25 server mono[24735]: Application started. Press Ctrl+C to shut down.
問題顯然是 systemd 對 case:
User
而不是user
:[Unit] Description=Jackett Daemon After=network-online.target [Service] Type=simple User=jackett Group=jackett ExecStart=/usr/bin/mono --debug /opt/Jackett/JackettConsole.exe --NoRestart [Install] WantedBy=multi-user.target
參考: