gpt4 book ai didi

ruby-on-rails - 为什么我在系统启动的时候启动unicorn会报错?

转载 作者:数据小太阳 更新时间:2023-10-29 08:01:31 25 4
gpt4 key购买 nike

这是我的 unicorn (/etc/init.d/unicorn) 初始化脚本:

#! /bin/sh

PATH=/home/josue/.rvm/gems/ruby-1.9.3-p0/bin:/home/josue/.rvm/gems/ruby-1.9.3-p0@global/bin:/home/josue/.rvm/rubies/ruby-1.9.3-p0/bin:/home/josue/.rvm/bin:/usr/local/sbin:$
DAEMON=/home/josue/.rvm/gems/ruby-1.9.3-p0/bin/unicorn_rails

DAEMON_OPTS="-c /home/josue/sped/current/unicorn.rb -E production -D"
NAME=unicorn_rails
DESC=unicorn_rails
PID=/home/josue/sped/shared/pids/unicorn.pid

case "$1" in
start)
echo -n "Starting $DESC: "
exec $DAEMON $DAEMON_OPTS
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
kill -QUIT `cat $PID`
echo "$NAME."
;;
restart)
echo -n "Restarting $DESC: "
kill -QUIT `cat $PID`
sleep 1
$DAEMON $DAEMON_OPTS
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration: "
kill -HUP `cat $PID`
echo "$NAME."
;;
*)
echo "Usage: $NAME {start|stop|restart|reload}" >&2
exit 1
;;
esac

exit 0

当我以普通用户身份运行 /etc/init.d/unicorn start 时,它工作正常,但是当我尝试以 root 身份运行时,结果如下:

Starting unicorn_rails: /home/josue/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find unicorn (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)
from /home/josue/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /home/josue/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems.rb:1210:in `gem'
from /home/josue/.rvm/gems/ruby-1.9.3-p0/bin/unicorn_rails:18:in `<main>'

因此,当服务器启动时,unicorn 不会自动加载。

我正在使用:

  • Ubuntu 10.04
  • rvm
  • ruby 1.9.3-p0

最佳答案

有几种方法可以让它工作:

  1. 按照您的代码:

    PATH=/home/josue/.rvm/gems/ruby-1.9.3-p0/bin:/home/josue/.rvm/gems/ruby-1.9.3-p0@global/bin:/home/josue/.rvm/rubies/ruby-1.9.3-p0/bin:/home/josue/.rvm/bin:$PATH
    GEM_HOME=/home/josue/.rvm/gems/ruby-1.9.3-p0
    GEM_PATH=/home/josue/.rvm/gems/ruby-1.9.3-p0:/home/josue/.rvm/gems/ruby-1.9.3-p0@global
  2. 使用 rvm 包装器:https://rvm.io/integration/init-d/

  3. 或其他人:https://rvm.io/integration/cron/

关于ruby-on-rails - 为什么我在系统启动的时候启动unicorn会报错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7973407/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com