poise / application_python

A Chef cookbook to deploy Python applications.
Apache License 2.0
73 stars 108 forks source link

application_python failing to install gunicorn on first deploy #40

Closed lukas-hetzenecker closed 9 years ago

lukas-hetzenecker commented 10 years ago

The first deploy of an app that has the gunicorn service enabled fails with the following error:

[2013-12-15T07:15:38+00:00] FATAL: Chef::Exceptions::EnclosingDirectoryDoesNotExist: directory[/srv/splots/shared/env](/opt/aws/opsworks/releases/20131125133823_214/site-cookbooks/python/providers/virtualenv.rb line 31) had an error: Chef::Exceptions::EnclosingDirectoryDoesNotExist: Parent directory /srv/splots/shared does not exist, cannot create /srv/splots/shared/env

There is also a longer description of this bug on stackoverflow: http://stackoverflow.com/questions/20351292/application-python-failing-to-install-gunicorn-on-first-deploy

keitwb commented 10 years ago

I am having this same problem.

The issue seems to be that when the provider in this project installs gunicorn (https://github.com/poise/application_python/blob/master/providers/gunicorn.rb#L32), it is passing the virtualenv to the gunicorn_install action, which attempts to create the virtualenv if it doesn't exist. Unfortunately the parent directory for the virtualenv doesn't exist until the before_deploy action is run (https://github.com/poise/application/blob/92081d6ae092538333631f082a211f1504fb7e30/providers/default.rb#L25), which is after before_compile.

I could imagine one hackish way to fix it would be to manually create the virtualenv parent folder in the before_compile step of this cookbook, but this is definitely a bug regardless. Until it's fixed perhaps you can try that in your own cookbook before the call to application_python. I'm afraid I don't know the code base of these cookbook well enough to suggest any alternative solutions to you. Hopefully somebody else knows of a good fix so that we don't have to resort to hacks in our own cookbooks to get this working.

kplimack commented 10 years ago

@keitwb . Same issue here. did you figure out a fix? This worked for a long time, just tried firing up an old cookbook and its bombing out here.

keitwb commented 10 years ago

@kplimack, I ended up just creating the shared folder manually in my own application recipe, just before calling this cookbook's resources. I never did figure out a simple way to patch this to avoid having to do that.

coderanger commented 9 years ago

This should be resolved now.