unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* Confused about restart/upgrade w. bundler and symlinks
@ 2013-10-23  8:35 Carlos Peñas
  2013-10-23 16:02 ` Eric Wong
  0 siblings, 1 reply; 3+ messages in thread
From: Carlos Peñas @ 2013-10-23  8:35 UTC (permalink / raw)
  To: mongrel-unicorn

Hi.

I'm having an issue using unicorn with bundler on a rails ap deployed by
capistrano

Im using bundler 1.3.5 (tried 1.4rc0 also) I'm deploying with
capistrano, version is irrelevant, the issue hit me when keep releases
is reached and 'current' symlink where "bundle unicorn" process was
initially started.

Im using also unicorn 4.6.3 and ruby 2.0.0, it is a Rails 4 app runing
on linux 3.2 64

I'm restarting with a init.d script which sends a HUP to master (restart) or USR2 (upgrade)

bundled gems are vendorized and stored in a shared location between
deploys. pids and logs also.

In the config have lines for:

Unicorn::HttpServer::START_CTX[0] pointing to the binary in the bundle

and ENV["BUNDLE_GEMFILE"] pointing to "current" path of the gemfile

When a capistrano deploy reach the :keep_releases and deletes a release
directory where unicorn was previously started the master kills all the
workers an the new worker get in a death loop telling that they can not
locate 'rack/builder'.

I traced the process and the diying worker threads are looking for files
in the deleted release directory.

Problem is crystal clear to me. Unix dereferences 'current' directory
and store it in the proc environment so when the referenced directory
dissapear unicorn workers aren't able to locate cwd. But I can't find a
workarround which let me use a deploy tool and bundle to keep project
gems.

So What i'm missing? is there a best practice I'm not following?.

Thanks

-- 
Carlos Peñas San José
carlos@adoptales.es

_______________________________________________
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] 3+ messages in thread

* Re: Confused about restart/upgrade w. bundler and symlinks
  2013-10-23  8:35 Confused about restart/upgrade w. bundler and symlinks Carlos Peñas
@ 2013-10-23 16:02 ` Eric Wong
  2013-10-23 17:18   ` Daniel Condomitti
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Wong @ 2013-10-23 16:02 UTC (permalink / raw)
  To: unicorn list

Carlos Peñas <theistian@gmx.com> wrote:
> Hi.
> 
> I'm having an issue using unicorn with bundler on a rails ap deployed by
> capistrano
> 
> Im using bundler 1.3.5 (tried 1.4rc0 also) I'm deploying with
> capistrano, version is irrelevant, the issue hit me when keep releases
> is reached and 'current' symlink where "bundle unicorn" process was
> initially started.
> 
> Im using also unicorn 4.6.3 and ruby 2.0.0, it is a Rails 4 app runing
> on linux 3.2 64
> 
> I'm restarting with a init.d script which sends a HUP to master (restart) or USR2 (upgrade)
> 
> bundled gems are vendorized and stored in a shared location between
> deploys. pids and logs also.
> 
> In the config have lines for:
> 
> Unicorn::HttpServer::START_CTX[0] pointing to the binary in the bundle

Actually, I'm not 100% sure if that's correct
I'll let somebody who uses bundler correct me, but you *might* need
 to use something like this instead:

  start_ctx = Unicorn::HttpServer::START_CTX
  start_ctx[0] = "bundle"
  start_ctx[:argv] = %w(exec unicorn).concat(start_ctx[:argv])

> and ENV["BUNDLE_GEMFILE"] pointing to "current" path of the gemfile

> When a capistrano deploy reach the :keep_releases and deletes a release
> directory where unicorn was previously started the master kills all the
> workers an the new worker get in a death loop telling that they can not
> locate 'rack/builder'.

Wait, this means you've had multiple deploys fail to reach :keep_releases
and have it delete directories?  Might not be easy to recover from...

Can you check the output of:

	tr '\0' '\n' < /proc/$PID/environ

On the killing master process for anything that looks like GEM/PATH/RUBY?
Perhaps something is out-of-date in one of those paths and not
unset/reset correctly by bundler.

> I traced the process and the diying worker threads are looking for files
> in the deleted release directory.
> 
> Problem is crystal clear to me. Unix dereferences 'current' directory
> and store it in the proc environment so when the referenced directory
> dissapear unicorn workers aren't able to locate cwd. But I can't find a
> workarround which let me use a deploy tool and bundle to keep project
> gems.
> 
> So What i'm missing? is there a best practice I'm not following?.

Are you setting working_directory in your config file?
That might fix some things up.  Can you also ask some bundler
users/developers for assistance?
_______________________________________________
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] 3+ messages in thread

* Re: Confused about restart/upgrade w. bundler and symlinks
  2013-10-23 16:02 ` Eric Wong
@ 2013-10-23 17:18   ` Daniel Condomitti
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Condomitti @ 2013-10-23 17:18 UTC (permalink / raw)
  To: unicorn list



On Wednesday, October 23, 2013 at 9:02 AM, Eric Wong wrote:

> Carlos Peñas <theistian@gmx.com (mailto:theistian@gmx.com)> wrote:
> > Hi.
> >  
> > I'm having an issue using unicorn with bundler on a rails ap deployed by
> > capistrano
> >  
> > Im using bundler 1.3.5 (tried 1.4rc0 also) I'm deploying with
> > capistrano, version is irrelevant, the issue hit me when keep releases
> > is reached and 'current' symlink where "bundle unicorn" process was
> > initially started.
> >  
> > Im using also unicorn 4.6.3 and ruby 2.0.0, it is a Rails 4 app runing
> > on linux 3.2 64
> >  
> > I'm restarting with a init.d script which sends a HUP to master (restart) or USR2 (upgrade)
> >  
> > bundled gems are vendorized and stored in a shared location between
> > deploys. pids and logs also.
> >  
> > In the config have lines for:
> >  
> > Unicorn::HttpServer::START_CTX[0] pointing to the binary in the bundle
>  
> Actually, I'm not 100% sure if that's correct
> I'll let somebody who uses bundler correct me, but you *might* need
> to use something like this instead:
>  
> start_ctx = Unicorn::HttpServer::START_CTX
> start_ctx[0] = "bundle"
> start_ctx[:argv] = %w(exec unicorn).concat(start_ctx[:argv])

I point to the binary in the bundled gemset using rubygems 1.8.24 and bundler 1.4.0pre1. This works for me while only keeping two releases around

Unicorn::HttpServer::START_CTX[0] = "/opt/app/application-name/current/vendor/bundle/ruby/2.0.0/bin/unicorn
_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2013-10-23 17:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-23  8:35 Confused about restart/upgrade w. bundler and symlinks Carlos Peñas
2013-10-23 16:02 ` Eric Wong
2013-10-23 17:18   ` Daniel Condomitti

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).