我有一个服务文件,它拒绝实际启动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指定的命令,则一切运行正常。该程序将一直运行,直到我实际命令它关闭。
这个问题一天来一直困扰着我,我离解决方案还差得很近。 任何有关我可能在做错事情的指示都将不胜感激。
答案 0 :(得分:0)
我已经解决了问题!!! 因为系统派生了screen命令,所以我需要将服务类型更改为“ forking”。 现在一切都完美。 通常是愚蠢的事情吸引您!