From: Graham Christensen <graham@grahamc.com>
To: mongrel-unicorn@rubyforge.org
Subject: Unicorn + RUnit Rails Not Killing Old Master
Date: Mon, 20 May 2013 12:46:08 -0400 [thread overview]
Message-ID: <kndk0a$she$1@ger.gmane.org> (raw)
Hi,
I'm deploying Unicorn on a Rails application with RUnit. Technically
I'm using Chef's deployment tools, if any of you are familiar with it
(https://github.com/opscode-cookbooks/application_ruby) but to be clear
they aren't doing anything magical, so this is purely an issue with
RUnit and Unicorn.
The TL;DR of the following post, which has lots of pastes (linking to
pastebins for easier reading:) when I run /etc/init.d/myzippykid
restart, the old unicorn master fails to die, causing the new master to
be stuck in a loop waiting to own port 8080. The new master never takes
over, as the old master never dies. When I manually kill the master,
the new one takes over just fine.
What am I missing in my restart process to make the old master exit?
--
More details:
When I deploy a new version of software, the unicorn master fails to
restart. Here is an example of my ps auxfg output after I run
`/etc/init.d/myzippykid restart` (which is symlinked to /usr/bin/sv):
https://gist.github.com/grahamc/35715c1a2c9717e461e3
When I run `killall unicorn`, the ruby script under runsvdir gets
replaced with the unicorn worker. This is because the ruby script is
attempting to bind to port 8080, which is already taken up by the
unicorn master process. As soon as the old master is out of the way,
its capable of binding.
Here is my unicorn configuration at /etc/unicorn/myzippykid.rb:
https://gist.github.com/grahamc/08aaed97c9b39cf68f01
Here is my /etc/sv/myzippykid/run script which is how runit runs my
unicorn daemon: https://gist.github.com/grahamc/7ca7e3942d19f60d339a
my bundle_wrapper.sh simply inits the environment with the proper ruby
and path: https://gist.github.com/grahamc/9760001e0e20c915d9e9
--
The contents of all my pastes for those of you without internet at time
of reading:
https://gist.github.com/grahamc/35715c1a2c9717e461e3:
runsvdir -P /etc/service log:
.............................................................................................................................................
\_ runsv myzippykid
\_ svlogd -tt ./main
\_ /bin/bash /opt/myzippykid/bundle_wrapper.sh exec unicorn -E
staging -c /etc/unicorn/myzippykid.rb
\_ ruby
/opt/myzippykid/deployment/releases/6328251212178494a6c82b11ec518dc4d1962f9c/vendor/bundle/ruby/2.0.0/bin/unicorn
-E staging -c /etc/unicorn/myzippykid.rb
unicorn master -E staging -c /etc/unicorn/myzippykid.rb
\_ unicorn worker[0] -E staging -c /etc/unicorn/myzippykid.rb
https://gist.github.com/grahamc/08aaed97c9b39cf68f01:
# What ports/sockets to listen on, and what options for them.
listen "8080", :tcp_nodelay => true, :backlog => 100
working_directory '/opt/myzippykid/deployment/current'
# What the timeout for killing busy workers is, in seconds
timeout 60
# Whether the app should be pre-loaded
preload_app false
# How many worker processes
worker_processes 1
# What to do before we fork a worker
before_fork do |server, worker|
sleep 1
end
https://gist.github.com/grahamc/7ca7e3942d19f60d339a:
#!/bin/bash
cd /opt/myzippykid/deployment/current
exec 2>&1
exec /usr/bin/chpst \
-u myzippykid:myzippykid \
/opt/myzippykid/bundle_wrapper.sh exec \
unicorn \
-E staging \
-c /etc/unicorn/myzippykid.rb
https://gist.github.com/grahamc/9760001e0e20c915d9e9:
#!/bin/bash
source /etc/profile.d/rbenv.sh
bundle $@
Thank you for your help,
-- Graham Christensen
_______________________________________________
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
next reply other threads:[~2013-05-20 16:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-20 16:46 Graham Christensen [this message]
2013-05-20 17:28 ` Unicorn + RUnit Rails Not Killing Old Master Eric Wong
2013-05-20 17:51 ` Graham Christensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/unicorn/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='kndk0a$she$1@ger.gmane.org' \
--to=graham@grahamc.com \
--cc=mongrel-unicorn@rubyforge.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).