我是运行Debian 6的新Linode / Linux用户。我试图让我的Unicorn服务器在启动时启动,但由于某种原因它不是,我无法追踪任何错误消息。 Nginx开始很好,我有一个多用户RVM安装。我的直觉是与RVM有关。这是unicorn_init.sh
中的/rails/todo
文件,/etc/init.d/unicorn
处有一个符号链接:
# unicorn_init.sh
#!/bin/sh
set -e
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/rails/todo
PID=$APP_ROOT/tmp/pids/unicorn.pid
CMD="$APP_ROOT/bin/unicorn_rails -D -c $APP_ROOT/config/unicorn.rb -E production"
GEM_HOME="/usr/local/rvm/gems/ruby-1.9.2-p290@global"
action="$1"
set -u
old_id="$PID.oldbin"
cd $APP_ROOT || exit 1
export GEM_HOME=$GEM_HOME
sig () {
test -s "$PID" && kill -$1 `cat $PID`
}
oldsig () {
test -s $old_pid && kill -$1 `cat $old_pid`
}
case $action in
start)
sig 0 && echo >&2 "Already running" && exit 0
su -c "$CMD" - root
;;
stop)
sig QUIT && exit 0
echo >&2 "Not running"
;;
force-stop)
sig TERM && exit 0
echo >&2 "Not running"
;;
restart|reload)
sig HUP && echo reloaded OK && exit 0
echo >&2 "Couldn't reload, starting '$CMD' instead"
su -c "$CMD" - root
;;
upgrade)
if sig USR2 && sleep 2 && sig 0 && oldsig QUIT
then
n=$TIMEOUT
while test -s $old_pid && test $n -ge 0
do
printf '.' && sleep 1 && n=$(( $n - 1 ))
done
echo
if test $n -lt 0 && test -s $old_pid
then
echo >&2 "$old_pid still exists after $TIMEOUT seconds"
exit 1
fi
exit 0
fi
echo >&2 "Couldn't upgrade, starting '$CMD' instead"
su -c "$CMD" - root
;;
reopen-logs)
sig USR1
;;
*)
echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>"
exit 1
;;
esac
我99%的方式让我的设置工作 - 任何建议都会非常感激。
以下是$ update-rc.d unicorn defaults
的输出:
update-rc.d: using dependency based boot sequencing
insserv: warning: script 'unicorn' missing LSB tags and overrides
insserv: There is a loop between service nginx and unicorn if stopped
insserv: loop involving service unicorn at depth 2
insserv: loop involving service nginx at depth 1
insserv: Stopping unicorn depends on nginx and therefore on system facility `$all' which can not be true!
insserv: exiting now without changing boot order!
update-rc.d: error: insserv rejected the script header
答案 0 :(得分:2)
update-rc.d:error:insserv拒绝了脚本标题
文件的开头如下:
# unicorn_init.sh
#!/bin/sh
shebang行(#!/bin/sh
)必须是文件的第一行。
我无法对循环检测消息发表评论,因为我之前从未见过它。你在/etc/init.d/nginx中说的可能是表达对独角兽的依赖,但我没有在unicorn init中看到任何表达对nginx的依赖,因此循环不清楚。
insserv:警告:脚本'unicorn'缺少LSB标记和覆盖
您应该将LSB信息添加到初始脚本http://wiki.debian.org/LSBInitScripts