aws / opsworks-cookbooks

Chef Cookbooks for the AWS OpsWorks Service
Other
1.06k stars 1.23k forks source link

unicorn::rails recipe is run before deploy directory is created, causing setup to fail #293

Closed ajsharp closed 9 years ago

ajsharp commented 9 years ago

The unicorn::rails recipe, which includes the nginx recipe, is being run as part of the setup phase. The effect of this is that the "shared" directory is trying to be created before it's parent, which is causing a failure. Here's the console output:

[2015-03-23T18:39:53+00:00] INFO: Processing directory[/srv/www/APPNAME/shared] action create (unicorn::rails line 3)

================================================================================
Error executing action `create` on resource 'directory[/srv/www/APPNAME/shared]'
================================================================================

Errno::ENOENT
-------------
No such file or directory - /srv/www/APPNAME

Resource Declaration:
---------------------
# In /var/lib/aws/opsworks/cache.stage2/cookbooks/deploy/definitions/opsworks_deploy_dir.rb

3:   directory "#{params[:path]}/shared" do
4:     group params[:group]
5:     owner params[:user]
6:     mode 0770
7:     action :create
8:     recursive true
9:   end
10: 

Compiled Resource:
------------------
# Declared in /var/lib/aws/opsworks/cache.stage2/cookbooks/deploy/definitions/opsworks_deploy_dir.rb:3:in `block in from_file'

directory("/srv/www/APPNAME/shared") do
params {:user=>"deploy", :group=>"www-data", :path=>"/srv/www/APPNAME", :name=>nil}
provider Chef::Provider::Directory
action [:create]
retries 0
retry_delay 2
path "/srv/www/APPNAME/shared"
recursive true
cookbook_name "unicorn"
recipe_name "rails"
mode 504
owner "deploy"
group "www-data"
end
ajsharp commented 9 years ago

I should add that I am trying to launch an instance from an AMI that was generated from this cookbook. I performed the suggested steps from the amazon guide on creating an AMI from an opsworks instance. It is rails / unicorn, ruby 2.1. I suspect the problem may be related to the recipes that run when an instance is shut down: deploy::rails-undeploy, opsworks_shutdown::default, nginx:stop.

kalinchuk commented 9 years ago

@ajsharp So how did you solve this?

ajsharp commented 9 years ago

Unfortunately I don't remember :(

On Monday, August 31, 2015, kalinchuk notifications@github.com wrote:

@ajsharp https://github.com/ajsharp So how did you solve this?

— Reply to this email directly or view it on GitHub https://github.com/aws/opsworks-cookbooks/issues/293#issuecomment-136397076 .

codegardenllc commented 9 years ago

Just in case someone runs into this, here is what I did: I added a custom JSON with the following:

{
  "deploy" : { 
    "app_name" : { 
      "deploy_to" : "/mnt/srv/www/app_name" 
    }
  }
}