首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法启动Unicorn

无法启动Unicorn
EN

Stack Overflow用户
提问于 2014-03-24 19:08:40
回答 2查看 3.4K关注 0票数 0

我想重新启动Unicorn,看看我在本地做的一些视图编辑。

我阻止了独角兽。由于某些原因,它将不会重新启动。

这是它给我的错误:

代码语言:javascript
复制
Executing /etc/rc.d/init.d/unicorn_loadmax start ..

/etc/rc.d/init.d/unicorn_loadmax: line 20: kill: (24317) - No such process
master failed to start, check stderr log for details

这是我的独角兽剧本

代码语言:javascript
复制
#!/bin/sh
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals

# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/home/deployer/loadmax/current
PID=/home/deployer/loadmax/shared/pids/unicorn.pid
CMD="cd /home/deployer/loadmax/current && bundle exec /home/deployer/loadmax/shared/bundle/ruby/1.9.1/bin/unicorn -D -c /home/deployer/loadmax/shared/config/unicorn.rb -E production"
AS_USER=deployer
action="$1"
set -u

old_pid="$PID.oldbin"

cd $APP_ROOT || exit 1

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" - $AS_USER
        ;;
stop)
        sig QUIT && exit 0
        echo >&2 "Not running"
        ;;
force-stop)
        sig TERM && exit 0
        echo >&2 "Not running"
        ;;
restart|reload)
        sig USR2 && echo reloaded OK && exit 0
        echo >&2 "Couldn't reload, starting '$CMD' instead"
        su -c "$CMD" - $AS_USER
        ;;
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" - $AS_USER
        ;;
reopen-logs)
        sig USR1
        ;;
*)
        echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>"
        exit 1
        ;;
esac

日志文件:

代码语言:javascript
复制
I, [2014-03-24T15:25:07.830877 #13704]  INFO -- : Refreshing Gem list
        SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
        This poses a security threat. It is strongly recommended that you
        provide a secret to prevent exploits that may be possible from crafted
        cookies. This will not be supported in future versions of Rack, and
        future versions will even invalidate your existing user cookies.

        Called from: /home/deployer/website/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/session/abstract_store.rb:28:in `initialize'.

/home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require': /home/deployer/website/releases/20140111043133/app/models/document.rb:26: syntax error, unexpected tCONSTANT, expecting keyword_end (SyntaxError)
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:359:in `require_or_load'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:502:in `load_missing_constant'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:192:in `block in const_missing'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:190:in `each'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:190:in `const_missing'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/ext/module.rb:36:in `const_missing'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:229:in `block in constantize'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:228:in `each'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:228:in `constantize'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:259:in `safe_constantize'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/core_ext/string/inflections.rb:66:in `safe_constantize'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_controller/metal/params_wrapper.rb:152:in `_default_wrap_model'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_controller/metal/params_wrapper.rb:169:in `_set_wrapper_defaults'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_controller/metal/params_wrapper.rb:133:in `inherited'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/abstract_controller/railties/routes_helpers.rb:7:in `block (2 levels) in with'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_controller/railties/paths.rb:7:in `block (2 levels) in with'
    from /home/deployer/website/releases/20140111043133/app/controllers/documents_controller.rb:1:in `<top (required)>'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:359:in `require_or_load'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:313:in `depend_on'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:225:in `require_dependency'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:438:in `each'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:438:in `block in eager_load!'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:436:in `each'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:436:in `eager_load!'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /home/deployer/website/releases/20140111043133/config/environment.rb:5:in `<top (required)>'
    from config.ru:4:in `require'
    from config.ru:4:in `block in <main>'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
    from config.ru:1:in `new'
    from config.ru:1:in `<main>'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn.rb:44:in `eval'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn.rb:44:in `block in builder'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:722:in `call'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:722:in `build_app!'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:140:in `start'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/bin/unicorn:126:in `<top (required)>'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `load'
    from /home/deployer/website/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `<main>'

document.rb

代码语言:javascript
复制
class Document < ActiveRecord::Base
  attr_accessible :description, :filename, :filesize, :filetype, :name, :user_id
  belongs_to :user

  FILENAME_FORMAT = /^[a-zA-Z0-9_\.]+$/
  BAD_FILETYPE_FORMAT = /^Badfiletype$/
  MIME_HASH = { "doc" => "application/msword",
                "docx" => "application/msword",
                "dot" => "application/msword",
                "xml" => "application/xml",
                "pdf" => "application/pdf",
                "tif" => "image/tif",
                "txt" => "text/plain",
                "xls" => "application/vnd.ms-excel",
                "xlsx" => "application/vnd.ms-excel",
                "ppt" => "application/vnd.ms-powerpoint",
                "pptx" => "application/vnd.ms-powerpoint",
                "gif" => "image/gif",
                "png" => "image/png",
                "jpg" => "image/jpg",
                "jpeg" => "image/jpg",
                "ps" => "application/postscript",
                "rtf" => "application/rtf",
                "zip" => "application/zip" }

  validates_numericality_of :filesize, less_than: 50M
  validates_format_of :filename, with: FILENAME_FORMAT
  validates_format_of :filetype, without: BAD_FILETYPE_FORMAT
end

我昨天确实换了26号线..。

2048至50米

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-03-24 20:30:57

您的脚本崩溃在以下一行:

代码语言:javascript
复制
test -s "$PID" && kill -$1 `cat $PID`

$PID设置为:

代码语言:javascript
复制
PID=/home/deployer/loadmax/shared/pids/unicorn.pid

test -s检查该文件是否存在,并且其大小大于零。

尝试删除此文件,然后再次运行脚本。

至于第26行-尝试删除M -它不是一个数字.-简单地说是50

票数 0
EN

Stack Overflow用户

发布于 2014-03-24 19:46:10

您应该检查日志中是否有确切的错误。但是,一个简单的修复方法是终止进程并重新启动独角兽。

代码语言:javascript
复制
ps aux | grep unicorn

然后,在那里找到主进程。

代码语言:javascript
复制
kill <process-id>

然后,再试着启动服务器。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22618439

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档