Feedback

type to search

Which unicorn.rb config file to do use ?

Asked by

I want deploy shapado with unicorn. But I want to know which is your unicorn config file to advice ?

I use this one :

# Use at least one worker per core
worker_processes 2

# Help ensure your application will always spawn in the symlinked "current" directory that Capistrano sets up
working_directory "/var/rails/shapado/site/current"

# Listen on a Unix domain socket, use the default backlog size
listen "/var/rails/shapado/site/shared/pids/unicorn-shapado.sock", :backlog => 1024

# Nuke workers after 30 seconds instead of 60 seconds (the default)
timeout 30

# Lets keep our process id's in one place for simplicity
pid "/var/rails/shapado/site/shared/pids/unicorn.pid"

# Logs are very useful for trouble shooting, use them
stderr_path "/var/rails/shapado/site/shared/log/shapado-stderr.log"
stdout_path "/var/rails/shapado/site/shared/log/shapado-stdout.log"

# Use "preload_app true"
preload_app true

GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true

before_fork do |server, worker|
  # the following is highly recomended for Rails + "preload_app true"
  # as there's no need for the master process to hold a connection
  defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
  MongoMapper.database.connection.close

  old_pid = '/tmp/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
    # someone else did our job for us
    end
  end

end

after_fork do |server, worker|
  defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection

  ##
  # Start Mongo
  begin
    include MongoMapper
    MongoMapper.database.connection.connect_to_master
  rescue
    RAILS_DEFAULT_LOGGER.error("Couldn't connect to Mongo Server")
  end

end
NN comments
spacecowboy
-

Haven’t started looking into unicorn deployment yet so any guidelines &or advice would be highly helpful SP

spacecowboy
-
.mougel tres bien, nicely shows shapado in language mode

or Cancel

Your answer

You need to join Shapado to complete this action, click here to do so.