* Capistrano and Unicorn
@ 2010-02-18 20:41 Steve Klabnik
2010-02-18 23:31 ` Michael Guterl
0 siblings, 1 reply; 2+ messages in thread
From: Steve Klabnik @ 2010-02-18 20:41 UTC (permalink / raw)
To: unicorn list
Anyone have any tips for using Capistrano with unicorn?
I'm following what GitHub did (http://github.com/blog/517-unicorn) ,
and for some reason, my old master isn't dying correctly. If I `pkill
-9 unicorn_rails && unicorn_rails` the new code shows up. I'm thinking
the problem may be with how capistrano uses the 'current' directory as
a symlink.
That config's before_fork seems to make sense to me; I might just be
doing something stupid.
Here's my config, for reference:
# Use at least one worker per core if you're on a dedicated server,
# more will usually help for _short_ waits on databases/caches.
worker_processes 16
working_directory "/home/git/site/current" # available in 0.94.0+
# listen on both a Unix domain socket and a TCP port,
# we use a shorter backlog for quicker failover when busy
listen "/tmp/.sock", :backlog => 64
listen 8080, :tcp_nopush => true
timeout 600
pid "/var/run/unicorn.pid"
# some applications/frameworks log to stderr or stdout, so prevent
# them from going to /dev/null when daemonized here:
stderr_path "/var/log/unicorn.stderr.log"
stdout_path "/var/log/unicorn.stdout.log"
# combine REE with "preload_app true" for memory savings
# http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
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!
old_pid = RAILS_ROOT + '/tmp/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
# someone else did our job for us
end
end
end
after_fork do |server, worker|
# the following is *required* for Rails + "preload_app true",
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
I am using ree, so preload_app should be in effect.
Thanks in advance.
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Capistrano and Unicorn
2010-02-18 20:41 Capistrano and Unicorn Steve Klabnik
@ 2010-02-18 23:31 ` Michael Guterl
0 siblings, 0 replies; 2+ messages in thread
From: Michael Guterl @ 2010-02-18 23:31 UTC (permalink / raw)
To: unicorn list
On Thu, Feb 18, 2010 at 3:41 PM, Steve Klabnik <steve@steveklabnik.com> wrote:
> Anyone have any tips for using Capistrano with unicorn?
>
Here's the init script we're using to manage unicorn:
http://gist.github.com/308216 some of it may be of use, I can't
remember where we originally found it.
We call `/etc/init.d/unicorn upgrade` in our deploy:restart task.
> I'm following what GitHub did (http://github.com/blog/517-unicorn) ,
> and for some reason, my old master isn't dying correctly. If I `pkill
> -9 unicorn_rails && unicorn_rails` the new code shows up. I'm thinking
> the problem may be with how capistrano uses the 'current' directory as
> a symlink.
>
<snip>
Also be sure to check out http://unicorn.bogomips.org/SIGNALS.html it
is very comprehensive.
Best,
Michael GUterl
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-02-18 23:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-18 20:41 Capistrano and Unicorn Steve Klabnik
2010-02-18 23:31 ` Michael Guterl
Code repositories for project(s) associated with this public inbox
https://yhbt.net/unicorn.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).