我使用一键式Rails、NGINX、Unicorn、MySQL droplet 设置来创建我的服务器,但我无法让 Unicorn 作为守护进程启动。这是我时的堆栈跟踪/etc/init.d/unicorn start:
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/unicorn-4.8.0/lib/unicorn/configurator.rb:659:in `parse_rackup_file': rackup file (config.ru) not readable (ArgumentError)
from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/unicorn-4.8.0/lib/unicorn/configurator.rb:77:in `reload'
from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/unicorn-4.8.0/lib/unicorn/configurator.rb:68:in `initialize'
from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/unicorn-4.8.0/lib/unicorn/http_server.rb:100:in `new'
from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/unicorn-4.8.0/lib/unicorn/http_server.rb:100:in `initialize'
from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/unicorn-4.8.0/bin/unicorn:126:in `new'
from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/unicorn-4.8.0/bin/unicorn:126:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p195/bin/unicorn:23:in `load'
from /usr/local/rvm/gems/ruby-2.0.0-p195/bin/unicorn:23:in `<main>'
from /usr/local/rvm/gems/ruby-2.0.0-p195/bin/ruby_executable_hooks:15:in `eval'
from /usr/local/rvm/gems/ruby-2.0.0-p195/bin/ruby_executable_hooks:15:in `<main>'
Run Code Online (Sandbox Code Playgroud)
当我which unicorn得到:
/usr/local/rvm/gems/ruby-2.0.0-p195/bin/unicorn这似乎应该是好的。
我已经尝试了所有我能想到的方法,其中一些包括:
No bin path suitable for lining wrapper. Try setting 'rvm_bin_path'.sudo gem install unicorn=> 无法构建本机扩展...(对于kgio 2.8.1). It's looking inextconf.rb 的 /usr/bin/ruby1.9.1`。我什至从未接触过低于 2.0 的 Ruby 版本。rvm remove 2.0.0-p353=> 一堆文件权限错误。RVM 也不知道是什么sudo意思。甘拜下风...如果我在后台(-D开关)启动它,它工作正常,但是一旦我与终端断开连接,进程仍然会被终止。我只是没有想法,已经在这两天了。
如果您希望我发布任何文件片段或运行命令,请告诉我。我不想用多余的信息填充这篇文章。
帮助我,AskUbuntu,你是我唯一的希望...
*编辑: * /etc/init.d/unicorn
set -e
NAME=unicorn
DESC="Unicorn web server"
. /lib/lsb/init-functions
if [ -f /etc/default/unicorn ]; then
. /etc/default/unicorn
fi
export PATH=/usr/local/rvm/gems/ruby-2.0.0-p195/bin:$PATH
export GEM_HOME=/usr/local/rvm/gems/ruby-2.0.0-p195
export GEM_PATH=/usr/local/rvm/gems/ruby-2.0.0-p195:/usr/local/rvm/gems/ruby-2.0.0-p195/gems:/usr/local/rvm/gems/ruby-2.0.0-p195@global/gems
DAEMON=/usr/local/rvm/gems/ruby-2.0.0-p195/bin/unicorn
PID=${PID-/run/unicorn.pid}
run_by_init() {
([ "${previous-}" ] && [ "${runlevel-}" ]) || [ "${runlevel-}" = S ]
}
exit_with_message() {
if ! run_by_init; then
log_action_msg "$1 Not starting."
fi
exit 0
}
check_config() {
if [ $CONFIGURED != "yes" ]; then
exit_with_message "Unicorn is not configured (see /etc/default/unicorn)."
fi
}
check_app_root() {
if ! [ -d $APP_ROOT ]; then
exit_with_message "Application directory $APP_ROOT is not exist."
fi
}
set -u
case "$1" in
start)
check_config
check_app_root
log_daemon_msg "Starting $DESC" $NAME || true
if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $UNICORN_OPTS; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
stop)
log_daemon_msg "Stopping $DESC" $NAME || true
if start-stop-daemon --stop --signal QUIT --quiet --oknodo --pidfile $PID; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
force-stop)
log_daemon_msg "Forcing stop of $DESC" $NAME || true
if start-stop-daemon --stop --quiet --oknodo --pidfile $PID; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" $NAME || true
start-stop-daemon --stop --quiet --oknodo --pidfile $PID
sleep 1
if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $UNICORN_OPTS; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
reload)
log_daemon_msg "Reloading $DESC" $NAME || true
if start-stop-daemon --stop --signal HUP --quiet --oknodo --pidfile $PID; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
reopen-logs)
log_daemon_msg "Relopening log files of $DESC" $NAME || true
if start-stop-daemon --stop --signal USR1 --quiet --oknodo --pidfile $PID; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
status)
status_of_proc -p $PID $DAEMON $NAME && exit 0 || exit $?
;;
*)
log_action_msg "Usage: $0 <start|stop|restart|force-reload|reload|force-stop|reopen-logs|status>" || true
exit 1
;;
esac
Run Code Online (Sandbox Code Playgroud)
/etc/default/unicorn
# Change parameters below to appropriate values and set CONFIGURED to yes.
CONFIGURED=yes
# Default timeout until child process is killed during server upgrade,
# it has *no* relation to option "timeout" in server's config.rb.
TIMEOUT=60
# Path to your web application, sh'ld be also set in server's config.rb,
# option "working_directory". Rack's config.ru is located here.
APP_ROOT=/home/rails/current/
# Server's config.rb, it's not a rack's config.ru
CONFIG_RB=/home/unicorn/unicorn.conf
# Where to store PID, sh'ld be also set in server's config.rb, option "pid".
PID=/home/unicorn/pids/unicorn.pid
UNICORN_OPTS="-D -c $CONFIG_RB -E production"
PATH=/usr/local/rvm/rubies/ruby-2.0.0-p195/bin:/home/unicorn/.rvm/bin:/usr/local/sbin:/usr/bin:/bin:/sbin:$
~
Run Code Online (Sandbox Code Playgroud)
编辑2:
成功!
的长期跟踪CHOWNs和CHMODs更高版本(针对不同的麒麟日志和PID文件),我只是得到了一个master failed to start, check stderr log for details,当我尝试/etc/init.d/unicorn/,但我的unicorn.stderr.log文件是空白的。跟踪更多配置文件,导致我找到一些错误日志,指出某些 unicorn/pid/ 目录不可写。稍作CHOWN动作后,一切正常。
谢谢本!
当unicorn \xe2\x80\x94 或任何Rack 兼容的服务器进程\xe2\x80\x94 运行时,它需要一个rackup ( .ru) 文件来告诉它要做什么。如果你不指向它,它就不知道该提供什么。我想说的脚本/etc/init.d/unicorn不包含项目的rackup 文件的完整路径,但它需要它。如今,大多数(如果不是全部)Rails 应用程序都包含一个作为 Rails 项目生成器 ( config.ru) 的一部分。
您遵循的指南指示您将代码放置在 中/home/rails,但将其配置文件放置在其他位置 ( /home/unicorn/unicorn.conf)。在我见过的大多数设置中,该文件的内容通常驻留在它所服务的 Rails 目录的根目录中,但这没什么大不了的。
该指南在一个单独的文件中包含大量配置/etc/default/unicorn,我猜测这可能是罪魁祸首。你能发布该文件的来源吗?
| 归档时间: |
|
| 查看次数: |
9152 次 |
| 最近记录: |