Mr.*_*r.D 8 server bash services systemd
<我已经创建*.service并将它放在我的/etc/systemd/system文件夹中:
[Unit]
Description=WSO2 IoT Message broker
[Service]
Environment="JAVA_HOME=/usr/lib/jvm/java-8-oracle"
Type=forking
ExecStart=/home/ubuntu/wso2iot-3.1.0/bin/broker.sh
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
我想运行 WSO2 物联网服务器的其中之一,但这并不重要。
当我bash手动启动这个脚本时,它会加载很长时间并保持在启动模式,因为它运行类似 Web 服务器应用程序的东西,然后使用特定端口。
当我像这样启动这个服务时:
sudo systemctl start myservice.service
Run Code Online (Sandbox Code Playgroud)
过了好久才说: Start operation timed out. Terminating.
我需要让这个服务永远启动,直到我手动停止它。
我在服务配置文件中遗漏了什么?
将Type您的服务脚本的设置为simple或oneshot。取决于启动的 shell 脚本的行为。
Type为simple Type为oneshot完成更改后,重新加载配置systemctl daemon-reload并启动服务。