<我已经创建了*.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我想要运行一个WSO2 IoT服务器,但这并不重要。
当我手动启动这个bash脚本时,它会加载很长时间,并保持启动模式,因为它运行类似web服务器应用程序的东西,然后使用特定的端口。
当我像这样启动这项服务时:
sudo systemctl start myservice.service这需要很长时间,然后说:Start operation timed out. Terminating.
我需要让这个服务永远启动,直到我手动停止它。
我在服务配置文件中遗漏了什么?
发布于 2017-09-08 13:04:12
将服务脚本的Type设置为simple或oneshot。取决于启动的shell脚本的行为。
Type设置为simpleType设置为oneshot完成更改后,用systemctl daemon-reload重新加载配置并启动服务。
发布于 2020-04-22 18:33:50
我还必须添加(或者是因为我最终重新启动了,而TimeoutSec实际上并没有什么区别?)
TimeoutSec=0如https://bugzilla.redhat.com/show_bug.cgi?id=1446015#c7所述
我自己的系统上的man systemd.service命令告诉我,应该为此使用infinity。我想这两种方法都有用。
就像这样(不管GuessMainPID是什么,但这就是我当前工作的文件的样子):
/etc/systemd/system/foo@..service
[Service]
Type=simple
TimeoutSec=0
GuessMainPID=false
ExecStart=/bin/bash -c "funny stuff %I"我的服务是从udev规则(如http://blog.fraggod.net/2012/06/16/proper-ish-way-to-start-long-running-systemd-service-on-udev-event-device-hotplug.html中)触发的,不知道这是否有任何区别。对于任何想知道如何获得超时日志的人,我必须运行journalctl | tail来查看我的udev规则和服务刚刚产生了哪些错误。
https://askubuntu.com/questions/953920
复制相似问题