我想在啓動Raspberry Pi時啓動thin Web服務器。在啓動時在Raspberry PI上啓動瘦服務器
我在/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:
您是否考慮過使用nginx + passenger?請參閱https://github.com/meinside/rails-on-raspberrypi或http://brianmilco.blogspot.de/2013/02/chiliproject-nginx-and-passenger-on.html#!/2013/02/chiliproject -nginx-and-passenger-on.html作爲首發... – theldoria
爲什麼你會選擇這個選項。我很喜歡這個事實,即它在開發時與軌道集成良好。只需將gem添加到Gemfile並按照正常情況啓動服務器:'rails s'。 – Besi
毫無疑問,它的發展很好。但是,對於我來說,您嘗試讓您通過運行Web服務器爲應用程序提供RPi引導。這聽起來像是我的產品,應該使用更高性能的服務器......當然,瘦可能已足夠供個人使用。 – theldoria