我想重新启动Unicorn以查看我在某些视图上进行的本地编辑。
我能够阻止独角兽。由于某种原因,它不会重新启动。
这是它给我的错误:
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
这是我的独角兽脚本
#!/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
日志文件:
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
我DID更改第26行昨天......
将2048改为50M
答案 0 :(得分:0)
您应该检查日志以确定错误。但是,一个简单的解决方法是终止进程并重新启动独角兽。
ps aux | grep unicorn
然后,在那里找到主进程。
kill <process-id>
然后,尝试再次启动服务器。
答案 1 :(得分:0)
您的脚本在以下行崩溃:
test -s "$PID" && kill -$1 `cat $PID`
$PID
设置为:
PID=/home/deployer/loadmax/shared/pids/unicorn.pid
和test -s
检查文件是否存在,并且大小大于零。
尝试删除此文件,然后再次运行脚本。
至于第26行 - 尝试删除M
- 它不是一个数字...... - 只需放50