如何使用config / unicorn / unicorn.rb文件配置参数更改unicorn的默认端口号。我需要在同一台机器上使用nginx运行两个独角兽,我该如何实现?现在我得到的端口地址已被占用错误。
app_dir = "/home/rails/apps/app_name/current"
shared_dir = "/home/rails/apps/app_name/shared"
env = "staging"
# Set unicorn options
worker_processes 1
preload_app true
timeout 30
# Fill path to your app
working_directory app_dir
# Set up socket location
listen "#{shared_dir}/sockets/unicorn.admin.sock", :backlog => 64
# Loging
stderr_path "#{shared_dir}/log/unicorn.stderr.log"
stdout_path "#{shared_dir}/log/unicorn.stdout.log"
# Set master PID location
pid "#{shared_dir}/pids/unicorn.admin.pid"
before_fork do |server, worker|
# server.listen(addr, :tries => -1, :delay => 5, :tcp_nopush => true)
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
old_pid = "#{server.config[:pid]}.oldbin"
if File.exists?(old_pid) && server.pid != old_pid
begin
sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
Process.kill(sig, File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
# someone else did our job for us
end
end
end
after_fork do |server, worker|
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
end
before_exec do |server|
ENV['BUNDLE_GEMFILE'] = "#{app_dir}/Gemfile"
end
我收到此错误:
/shared/sockets/unicorn.admin.sock (Errno::EADDRINUSE)
答案 0 :(得分:0)
好像你使用套接字连接。在这种情况下,您必须为此行使用uniq条目:
# Set up socket location
listen "#{shared_dir}/sockets/unicorn<X>.admin.sock", :backlog => 64