根据网络上的各种入门指南,我从未安装 daemontools 到自动运行简单服务所使用的步骤顺序如下(在 Ubuntu 14.04 上):
$ sudo apt-get install daemontools
$ sudo apt-get install daemontools-run # not clear if this is necessary
$ sudo apt-get install csh # unsure why csh would be needed to run dt
$ sudo mkdir /service
$ sudo mkdir /service/test
$ sudo chmod 1755 /service/test
$ vi /service/test/run # see below
$ vi /etc/rc.local # see below
$ # tried power cycling here too
$ sudo svstat /service/test # Why is supervise not running here?
/service/test/: supervise not running
$ sudo supervise /service/test/ > /dev/null &
[1] 2747
$ sudo svstat /service/test/
/service/test/: up (pid 2758) 1 seconds
#########################################################
# contents of /service/test/run:
#!/bin/sh
echo Running service
exec echo hello
#########################################################
# contents of /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
csh -cf '/usr/bin/svscanboot &'
exit 0
此外,手动运行svscanboot
似乎会立即终止(如果我在后台运行,也不会出现在 ps aux 输出中)。我遗漏了哪些设置步骤,或者我做错了什么?
答案1
我知道这是一个老问题,但我在从源代码安装守护进程工具时遇到了同样的问题。
然后我安装了 daemontools-run 包并且它开始工作。
我又继续往前走,试着看看有什么新东西。我在 /etc/inittab 中找到了一个文件,其中有以下调用:
#-- daemontools-run begin
SV:123456:respawn:/usr/bin/svscanboot
#-- daemontools-run end