Question

I wanted to restart Unicorn to check out some edits i did locally on some Views.

I was able to stop Unicorn. For some reason it will not restart.

here is the Error it is giving me:

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

here is my unicorn Script

#!/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

LOG FILE:

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

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

I DID change line 26 Yesterday...

changed 2048 to 50M

Was it helpful?

Solution

Your script crashes on the following line:

test -s "$PID" && kill -$1 `cat $PID`

$PID is set in:

PID=/home/deployer/loadmax/shared/pids/unicorn.pid

and test -s checks that the file exists, and has a size larger than zero.

Try deleting this file, then running the script again.


As for line 26 - try removing the M - it is not a number... - simply put 50

OTHER TIPS

You should check the logs for exact error. However, a simple fix would be to kill the process and restart the unicorn.

ps aux | grep unicorn

Then, locate the master process in there.

kill <process-id>

Then, try start the server again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top