启动时在Raspberry PI上启动瘦服务器

时间:2014-03-01 07:17:47

标签: ruby-on-rails ruby linux debian raspberry-pi

我想在重新启动Raspberry Pi时启动thin Web服务器。

我在/etc/thin/myapp.yml

中有所需的配置文件
---
chdir: "/home/pi/web-interface/current"
environment: production
address: 0.0.0.0
port: 3000
timeout: 30
log: "/home/pi/web-interface/shared/tmp/sockets/log/thin.log"
pid: tmp/pids/thin.pid
max_conns: 1024
max_persistent_conns: 100
require: []
wait: 30
threadpool_size: 20
servers: 1
daemonize: true

我这样做是为了安装瘦作为运行级别命令:

thin install
sudo /usr/sbin/update-rc.d -f thin defaults

从第二个命令我得到以下日志输出

update-rc.d: using dependency based boot sequencing
update-rc.d: warning: default stop runlevel arguments (0 1 6) do not match thin Default-Stop values (S 0 1 6)
insserv: warning: current stop runlevel(s) (0 1 6) of script `thin' overrides LSB defaults (0 1 6 S).

当我运行/etc/init.d/thin start时,服务器启动没有问题,因此设备启动时似乎出现了问题。

这是/etc/init.d/thin

#!/bin/sh
### BEGIN INIT INFO
# Provides:          thin
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: thin initscript
# Description:       thin
### END INIT INFO

# Original author: Forrest Robertson

# Do NOT "set -e"

# DAEMON=/home/pi/.rvm/gems/ruby-2.1.0/bin/thin
DAEMON=/home/pi/.rvm/wrappers/raspberrypi/thin
SCRIPT_NAME=/etc/init.d/thin
CONFIG_PATH=/etc/thin

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

case "$1" in
  start)
        say "Starting thin"
    $DAEMON start --all $CONFIG_PATH
    ;;
  stop)
        say "Stopping thin"
    $DAEMON stop --all $CONFIG_PATH
    ;;
  restart)
    $DAEMON restart --all $CONFIG_PATH
    ;;
  *)
    echo "Usage: $SCRIPT_NAME {start|stop|restart}" >&2
    exit 3
    ;;
esac

:

现在我的服务器无法正常启动,即使我的启动日志中有以下条目:

Sat Mar  1 08:19:45 2014: [start] /etc/thin/myapp.yml ...
Sat Mar  1 08:19:52 2014: [....] Starting NTP server: ntpd^[[?25l^[[?1c^[7^[[1G[^[[32m ok ^[[39;49m^[8^[[?25h^[[?0c.
Sat Mar  1 08:19:54 2014: [....] Starting OpenBSD Secure Shell server: sshd^[[?25l^[[?1c^[7^[[1G[^[[32m ok ^[[39;49m^[8^[[?25h^[[?0c.
Sat Mar  1 08:19:56 2014: Starting server on 0.0.0.0:3000 ... 
Sat Mar  1 08:19:56 2014: 

2 个答案:

答案 0 :(得分:0)

尝试从此行中删除S:

# Default-Stop:      S 0 1 6

答案 1 :(得分:0)

有一种叫做crontab的东西。也许它可以帮助你,在你的覆盆子开始时启动它。