Unicorn 配置
worker_processes 4
deploy_to = "/var/projects"
application = "QYBUser"
working_directory = "#{deploy_to}/#{application}/current"
#app_path working_directory
#listen "/tmp/#{application}.sock", :backlog => 256
listen "127.0.0.1:8080"
timeout 300
pid "#{deploy_to}/#{application}/shared/pids/unicorn.pid"
stderr_path "#{deploy_to}/#{application}/shared/log/unicorn.stderr.log"
stdout_path "#{deploy_to}/#{application}/shared/log/unicorn.stdout.log"
preload_app true
if GC.respond_to?(:copy_on_write_friendly=)
GC.copy_on_write_friendly = true
end
before_fork do |server, worker|
ENV['BUNDLE_GEMFILE'] = "#{working_directory}/Gemfile"
old_pid = "#{deploy_to}/#{application}/shared/pids/unicorn.pid.oldbin"
if File.exists?(old_pid) && server.pid != old_pid
begin
Process.kill("QUIT", File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
puts "Send 'QUIT' signal to unicorn error!"
end
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
ActiveRecord::Base.establish_connection
end
在发布成功后,执行 cap unicorn:start,运行结果如下
cap aborted!
TypeError: no implicit conversion of Rake::Task into String
/usr/local/rvm/gems/[email protected]/gems/capistrano-3.1.0/lib/capistrano/application.rb:15:in `run'
/usr/local/rvm/gems/[email protected]/gems/capistrano-3.1.0/bin/cap:3:in `<top (required)>'
/usr/local/rvm/gems/[email protected]/bin/cap:23:in `load'
/usr/local/rvm/gems/[email protected]/bin/cap:23:in `<main>'
/usr/local/rvm/gems/[email protected]/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/[email protected]/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)