Jason Su <[email protected]> wrote: > Hey guys, > > I'm sending USR2 to unicorn after cap deploy, and the old master is > getting replaced by a new master that doesn't work.
Can you expand on "doesn't work"? > Here are some similar threads I found ... > http://rubyforge.org/pipermail/mongrel-unicorn/2010-October/000733.html > http://rubyforge.org/pipermail/mongrel-unicorn/2010-October/000717.html > > I'm not using Bundler, and I have working_directory set in my unicorn config: I don't see where you have working_directory set below > Unicorn::HttpServer::START_CTX[0] = > "/opt/ruby-enterprise-1.8.7-2010.02/bin/unicorn_rails" You shouldn't need to touch START_CTX unless you're switching Ruby installations. It's rope to hang yourself with. I would simplify the config file as much as possible if you're debugging a problem. > pid "/var/www/lookbook/shared/pids/unicorn.pid" > stderr_path "/var/www/lookbook/shared/log/unicorn.stderr.log" > stdout_path "/var/www/lookbook/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| > STDERR.puts "BEFORE FORK:" > STDERR.puts ENV.inspect > defined?(ActiveRecord::Base) and > ActiveRecord::Base.connection.disconnect! The auto-killing old workers bit is fragile and you shouldn't need it unless you're very low on memory. > if old_pid != server.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 > end > end > > end > after_fork do |server, worker| > STDERR.puts "AFTER FORK:" > STDERR.puts ENV.inspect > > defined?(ActiveRecord::Base) and > ActiveRecord::Base.establish_connection > begin If you want to use user switching, the "user" directive which appeared a while back is much simpler and less error prone. > uid, gid = Process.euid, Process.egid > user, group = 'apache', 'apache' > target_uid = Etc.getpwnam(user).uid > target_gid = Etc.getgrnam(group).gid > worker.tmp.chown(target_uid, target_gid) > if uid != target_uid || gid != target_gid > Process.initgroups(user, target_gid) > Process::GID.change_privilege(target_gid) > Process::UID.change_privilege(target_uid) > end <snip> > Below is the output from unicorn.stderr.log.. I'm not sure if > UNICORN_FD has something to do with it? UNICORN_FD is absolutely for the old master tells the new master about the listener sockets to inherit. Don't touch it. <snip> > 3) cap deploy with symlinks + restart unicorn (kill -USR2) <snip> > addr=/var/www/lookbook/current/tmp/sockets/unicorn.sock fd=3 You should make sure your socket is in a shared path, not current. Whatever's in current gets replaced by Capistrano, right? I'm not sure if tmp is a symlink that's relinked on a new deploy, but there could be a race condition where the path to the socket is unreachable and nginx can't see it. -- Eric Wong _______________________________________________ Unicorn mailing list - [email protected] http://rubyforge.org/mailman/listinfo/mongrel-unicorn Do not quote signatures (like this one) or top post when replying
