mburns / application_nodejs

Chef cookbook for deploying and configuring Node.js applications
Apache License 2.0
10 stars 35 forks source link

Does not work with latest version of the application cookbook #4

Open duro opened 10 years ago

duro commented 10 years ago

I am trying to use this with version 4.1.4 of the application cookbook, and I get a failure.

================================================================================
Error executing action `force_deploy` on resource 'deploy_revision[app]'
================================================================================

NoMethodError
-------------
undefined method `application' for Chef::Resource::DeployRevision

Cookbook Trace:
---------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application_nodejs/providers/nodejs.rb:34:in `block (2 levels) in class_from_file'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:144:in `instance_eval'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:144:in `block (3 levels) in run_deploy'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:141:in `each'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:141:in `block (2 levels) in run_deploy'

Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb

123:   @deploy_resource = send(new_resource.strategy.to_sym, new_resource.name) do
124:     action force ? :force_deploy : :deploy
125:     scm_provider new_resource.scm_provider
126:     revision new_resource.revision
127:     repository new_resource.repository
128:     enable_submodules new_resource.enable_submodules
129:     user new_resource.owner
130:     group new_resource.group
131:     deploy_to new_resource.path
132:     ssh_wrapper "#{new_resource.path}/deploy-ssh-wrapper" if new_resource.deploy_key
133:     shallow_clone new_resource.shallow_clone
134:     rollback_on_error new_resource.rollback_on_error
135:     all_environments = ([new_resource.environment]+new_resource.sub_resources.map{|res| res.environment}).inject({}){|acc, val| acc.merge(val)}
136:     environment all_environments
137:     migrate new_resource.migrate
138:     all_migration_commands = ([new_resource.migration_command]+new_resource.sub_resources.map{|res| res.migration_command}).select{|cmd| cmd && !cmd.empty?}
139:     migration_command all_migration_commands.join(' && ')
140:     restart_command do
141:       ([new_resource]+new_resource.sub_resources).each do |res|
142:         cmd = res.restart_command
143:         if cmd.is_a? Proc
144:           app_provider.deploy_provider.instance_eval(&cmd) # @see libraries/default.rb
145:         elsif cmd && !cmd.empty?
146:           execute cmd do
147:             user new_resource.owner
148:             group new_resource.group
149:             environment all_environments
150:           end
151:         end
152:       end
153:     end
154:     purge_before_symlink (new_resource.purge_before_symlink + new_resource.sub_resources.map(&:purge_before_symlink)).flatten

Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:123:in `run_deploy'

deploy_revision("app") do
  provider Chef::Provider::Deploy::Revision
  action [:force_deploy]
  retries 0
  retry_delay 2
  deploy_to "/opt/app"
  environment {"NODE_ENV"=>"cookbook"}
  repository_cache "cached-copy"
  revision "dev"
  rollback_on_error true
  remote "origin"
  shallow_clone true
  scm_provider Chef::Provider::Git
  keep_releases 5
  cookbook_name :"app"
  repo "git@github.com:zehnergroup/xxx.git"
  user "xxx"
  group "xxx"
  git_ssh_wrapper "/opt/app/deploy-ssh-wrapper"
  restart_command #<Proc:0x00000004374098@/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:140>
  before_migrate #<Proc:0x000000043806b8@/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:160>
  before_symlink #<Proc:0x00000004380488@/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:163>
  before_restart #<Proc:0x00000004380258@/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:166>
  after_restart #<Proc:0x00000004380028@/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:169>
  shared_path "/opt/app/shared"
  destination "/opt/app/shared/cached-copy"
  current_path "/opt/app/current"
end

[2013-12-11T02:13:41+00:00] INFO: Running queued delayed notifications before re-raising exception
[2013-12-11T02:13:41+00:00] ERROR: Running exception handlers
[2013-12-11T02:13:41+00:00] ERROR: Exception handlers complete
[2013-12-11T02:13:41+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2013-12-11T02:13:41+00:00] FATAL: NoMethodError: deploy_revision[app] (/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb line 123) had an error: NoMethodError: undefined method `application' for Chef::Resource::DeployRevision
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

Everything in my cookbook works until I introduce the nodejs sub-resource

  application node["app"]["api"]["app_name"] do
    path              node["app"]["api"]["deploy_to"]
    owner             node["app"]["api"]["user"]
    group             node["app"]["api"]["group"]
    repository        node["app"]["api"]["repo"]["url"]
    revision          node["app"]["api"]["repo"]["branch"]
    deploy_key        node["app"]["api"]["repo"]["deploy_key"]
    environment_name  node["environment"]

    nodejs do
      npm true
      entry_point "server"
    end

    action :force_deploy
  end
gravitystorm commented 10 years ago

Related links:

conradev commented 10 years ago

@gravitystorm, any luck in fixing the issue?

gravitystorm commented 10 years ago

@conradev the commit linked above is working well for me, but I hesitate to make a PR since I'm not really sure why it works. It's just copying what happened in application_ruby.

Of course, if it works, and there's lots of people encountering the bug, maybe it's worth merging anyway? I'll leave that decision to you!

moreandres commented 10 years ago

Any luck on understanding if the fix was good enough to be pulled? I was updating my cookbooks and bumped into this thread due the issue.

paulczar commented 10 years ago

:+1: it would be great to see this patched and merged in.

Azrael808 commented 9 years ago

@conradev IDK if you're still maintaining this, but I just raised PR that seems to fix this issue:

https://github.com/conradev/application_nodejs/pull/16