Upstart 服务仅在启动时工作

Upstart 服务仅在启动时工作

我正在开发 Raspbian Jessie,我按如下方式编写了我的新贵脚本本教程。这是我的/etc/init/videostream.conf脚本文件。

# RPI Camera Service
description     "RPICAM streaming"
author          "My Name "

start on filesystem or runlevel [2345]
stop on shutdown or runlevel [016]

respawn
respawn limit 2 5

env HOME=/etc/default
umask 007
usage "videostream {start|stop|status|restart}"
script
    export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    export HOME="/etc/default"
    echo $$ > /var/run/videostream.pid
    exec /etc/default/videostream >/dev/null 2>&1 &
end script
post-start script
    echo "[`date`] videostream is Started" >> /var/log/videostream.log
end script
pre-start script
    echo "[`date`] videostream Starting" >> /var/log/videostream.log
end script
pre-stop script
    rm /var/run/videostream.pid
    killall -w -q raspivid
    killall -w -q ffmpeg
    echo "[`date`] videostream Stopping" >> /var/log/videostream.log
end script

我使用安装新贵sudo apt-get install upstart

重新启动系统后,服务启动良好并且工作正常。问题是,重新启动后直到系统正常工作,您无法停止该服务或启动它。

当询问状态时,您会得到以下信息:

sudo service videostream status
# Result
videostream stop/waiting

但是该服务正在工作,因为我可以看到流,并且根据日志文件,一切似乎都正常,除非该服务在启动时已启动两次。这是日志文件的一部分。

[Mon Jun 27 08:00:12 UTC 2016] videostream Starting
[Mon Jun 27 08:00:13 UTC 2016] videostream is Started
[Mon Jun 27 08:00:13 UTC 2016] videostream Starting
[Mon Jun 27 08:00:13 UTC 2016] videostream is Started

当我尝试启动该服务时,我得到以下信息:

sudo service videostream start
# Result
start: Job failed to start

请问有人可以帮助我吗?我真的不知道有什么问题。

相关内容