我有下面的 systemd 脚本,它应该重新启动我的展览者,但在服务器重启后,它根本没有启动。我尝试手动重启我的服务器(sudo reboot)很多次,我的展览者服务一次都没有运行。我不确定哪里出了问题。我需要手动重启我的 systemd 才能在系统重启后使其工作。如何调试出了什么问题?
[Unit]
Description= start zookeeper cluster
[Service]
Type=simple
Restart=always
RestartSec=3
LimitNOFILE=100000
LimitCORE=infinity
StartLimitInterval=0
WorkingDirectory=/opt/exhibitor/exhibitor-1.6.0/lib
ExecStart=/bin/sh -c "exec java -jar ./exhibitor-1.6.0.jar -c file --fsconfigdir /opt/exhibitor/conf --hostname some.host.com > exhibitor.out"
User=procapp
[Install]
WantedBy=multi-user.target
状态输出:
[email protected]:~$ sudo systemctl status exhibitor_server.service
● exhibitor_server.service - start zookeeper cluster
Loaded: loaded (/lib/systemd/system/exhibitor_server.service; disabled; vendor preset: enabled)
Active: inactive (dead)
答案1
尽管已经创建了 systemd 服务,但为了让它在启动时启动,你还需要使用 启用它systemctl
。具体操作如下:
sudo systemctl enable exhibitor_server.service