linux systemd未从ExecStart启动服务

fykwrbwg  于 2023-06-21  发布在  Linux
关注(0)|答案(2)|浏览(190)

我有一个服务文件,它拒绝实际启动ExecStart指令中指定的服务。
如果我从终端提示符运行完全相同的命令,一切都按预期工作。我已经检查了文件等的所有权限。但我做什么都启动不了这个程序
以下是我的服务文件:

[Unit]
Description=Start pjsip Pjsua client in background
After=network.target

[Service]
Type=simple
RestartSec=3
ExecStart=/usr/bin/screen -dmS Pjsua /usr/local/sbin/Pjsua --config-file /usr/local/sbin/pjsua.cfg

[Install]
WantedBy=multi-user.target

下面是日志文件的输出:

May 06 20:27:07 vring systemd[1]: pjsip.service: Trying to enqueue job pjsip.service/start/replace
May 06 20:27:07 vring systemd[1]: pjsip.service: Installed new job pjsip.service/start as 2553 
May 06 20:27:07 vring systemd[1]: pjsip.service: Enqueued job pjsip.service/start as 2553
May 06 20:27:07 vring systemd[1]: pjsip.service: About to execute: /usr/bin/screen -dmS Pjsua /usr/local/sbin/Pjsua --confif-file /usr/local/sbin/pjsua.cfg
May 06 20:27:07 vring systemd[1]: pjsip.service: Forked /usr/bin/screen as 11355
May 06 20:27:07 vring systemd[1]: pjsip.service: Changed dead -> running
May 06 20:27:07 vring systemd[1]: pjsip.service: Job pjsip.service/start finished, result=done
May 06 20:27:07 vring systemd[1]: Started Start pjsip Pjsua client in background.
May 06 20:27:07 vring systemd[1]: pjsip.service: Child 11355 belongs to pjsip.service
May 06 20:27:07 vring systemd[1]: pjsip.service: Main process exited, code=exited, status=0/SUCCESS
May 06 20:27:07 vring systemd[1]: pjsip.service: Changed running -> stop-sigterm
May 06 20:27:07 vring systemd[1]: pjsip.service: Child 11356 belongs to pjsip.service
May 06 20:27:07 vring systemd[1]: pjsip.service: cgroup is empty
May 06 20:27:07 vring systemd[1]: pjsip.service: Changed stop-sigterm -> dead
May 06 20:27:07 vring systemd[1]: pjsip.service: Collecting.

从上面看,似乎进程已经退出,我不明白为什么,因为它必须被命令这样做。
如果我从命令行运行为ExecStart指定的命令,它就能完美地工作。程序会一直运行直到我命令它关闭。
这个问题已经把我逼疯了大部分的一天,我没有接近一个解决方案。任何关于我可能做错了什么的建议都将非常感激。

7tofc5zh

7tofc5zh1#

我已经解决了这个问题!!!因为系统分叉了屏幕命令,我需要将服务类型更改为'forking'。现在一切都很完美。往往是愚蠢的事情让你陷入困境!

i7uq4tfw

i7uq4tfw2#

**谢谢!**我有同样的问题与'星人'(其中叉本身),这正是我需要的信息

相关问题