gpt4 book ai didi

linux - systemd 未从 ExecStart 启动服务

转载 作者:太空宇宙 更新时间:2023-11-04 05:46:46 24 4
gpt4 key购买 nike

我有一个服务文件,它拒绝实际启动 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 指定的命令,一切都会完美运行。该程序将一直保持事件状态,直到我实际命令它关闭为止。

这个问题已经让我抓狂了大半天,而且我还没有找到解决办法。任何有关我可能做错的事情的指示将非常感激。

最佳答案

问题我已经解决了!!!因为系统 fork 了屏幕命令,所以我需要将服务类型更改为“ fork ”。现在一切都很完美。通常是愚蠢的事情让你陷入困境!

关于linux - systemd 未从 ExecStart 启动服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56003674/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com