Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx does not start #342

Closed
crmckenzie opened this issue Mar 25, 2015 · 10 comments
Closed

nginx does not start #342

crmckenzie opened this issue Mar 25, 2015 · 10 comments

Comments

@crmckenzie
Copy link

2.7.5 of the cookbook breaks my deployment. The nginx service fails to start. It doesn't even get far enough to create any message in the error log. There is no error log.

I know you said that 2.7.5 is the last release in the old cookbook format and that it was deprecated, but something changed between 2.7.4 and 2.7.5 that breaks functionality that has worked for a long time.

I would like to ask that breaking changes follow semantic versioning and/or you publish a document explaining how to migrate what worked in 2.7.4 to what will work with later editions of the cookbook.

As of this moment I can lock the version to 2.7.4 and fix my deployment, but I'm not sure what changes I'd need to make to follow your upgrade path. Obviously, I would like to be able to take advantage of future enhancements to the cookbook.

In the interest of full disclosure I am new to chef and cookbook development, so it's entirely possible I'm doing something wrong or ill-advised. If you feel that that is the case I would be happy to discuss that with you.

Thank you for the work you've done on this cookbook, and for your time.

@miketheman
Copy link
Contributor

Hi @crmckenzie,

Thanks for your notes, and sorry if this broke something. Can you provide more context as to what broke?

When we release a version 3.0 of this cookbook, it's likely to have some more detailed announcement, and will likely not work with existing code, so I do recommend pinning to a known working version.
In general, that's a good idea, so that you don't get the most recent version of something that you haven't tested yet.

@crmckenzie
Copy link
Author

Here's my nginx.rb file from my cookbook:

passenger_version = '4.0.45'
node.default[:nginx][:passenger][:version] = passenger_version
node.default[:nginx][:passenger][:root] = "/var/lib/gems/1.9.1/gems/passenger-#{passenger_version}"
node.default[:nginx][:passenger][:ruby] = "/usr/bin/ruby"
node.default[:nginx][:default_site_enabled] = false
node.default[:nginx][:source][:modules] = ['nginx::passenger']
node.default[:nginx][:passenger][:packages][:debian]  = ['libcurl4-gnutls-dev','ruby1.9.1','ruby1.9.1-dev']

include_recipe 'apt'
include_recipe 'nginx::source'

template "#{node[:nginx][:dir]}/sites-enabled/00default" do
  source 'site.erb'
  owner  'root'
  group  node[:root_group]
  mode   '0644'
  notifies :reload, 'service[nginx]'
end

directory node[:mysite][:install_root] do
  owner node[:nginx][:user]
  group node[:nginx][:group]
  recursive true
  action :create
end

And here is the vagrant up output:

2015-03-25T20:59:44+00:00] INFO: Running queued delayed notifications before re-raising exception
==> default: [2015-03-25T20:59:44+00:00] INFO: template[nginx.conf] sending reload action to service[nginx] (delayed)
==> default: [2015-03-25T20:59:44+00:00] INFO: Processing service[nginx] action reload (nginx::source line 126)
==> default: [2015-03-25T20:59:44+00:00] DEBUG: service[nginx] you have specified a status command, running..
==> default: [2015-03-25T20:59:45+00:00] DEBUG: service[nginx] is running
==> default: [2015-03-25T20:59:45+00:00] INFO: service[nginx] reloaded
==> default: [2015-03-25T20:59:45+00:00] INFO: bash[compile_nginx_source] sending restart action to service[nginx] (delayed)
==> default: [2015-03-25T20:59:45+00:00] INFO: Processing service[nginx] action restart (nginx::source line 126)
==> default: [2015-03-25T20:59:45+00:00] DEBUG: service[nginx] you have specified a status command, running..
==> default: [2015-03-25T20:59:45+00:00] DEBUG: service[nginx] is running
==> default:
==> default: ================================================================================
==> default: Error executing action `restart` on resource 'service[nginx]'
==> default: ================================================================================
==> default:
==> default:
==> default: Mixlib::ShellOut::ShellCommandFailed
==> default: ------------------------------------
==> default: Expected process to exit with [0], but received '1'
==> default: ---- Begin output of /usr/bin/sv restart /etc/service/nginx ----
==> default: STDOUT: timeout: down: /etc/service/nginx: 1s, normally up, want up
==> default: STDERR:
==> default: ---- End output of /usr/bin/sv restart /etc/service/nginx ----
==> default: Ran /usr/bin/sv restart /etc/service/nginx returned 1
==> default:
==> default:
==> default: Resource Declaration:
==> default: ---------------------
==> default: # In /tmp/vagrant-chef/ce843c182594c695e0d2b0f9ec0c58ed/cookbooks/nginx/recipes/source.rb
==> default:
==> default: 126:   service 'nginx' do
==> default: 127:     supports       :status => true, :restart => true, :reload => true
==> default: 128:     reload_command "#{node['runit']['sv_bin']} hup #{node['runit']['service_dir']}/nginx"
==> default: 129:   end
==> default: 130: when 'bluepill'
==> default:
==> default:
==> default:
==> default: Compiled Resource:
==> default: ------------------
==> default: # Declared in /tmp/vagrant-chef/ce843c182594c695e0d2b0f9ec0c58ed/cookbooks/nginx/recipes/source.rb:126:in `from_file'
==> default:
==> default: service("nginx") do
==> default:   provider Chef::Provider::Service::Simple
==> default:   action "nothing"
==> default:   updated true
==> default:   supports {:status=>true, :restart=>true, :reload=>true}
==> default:   retries 0
==> default:   retry_delay 2
==> default:   service_name "nginx"
==> default:   running true
==> default:   pattern "nginx"
==> default:   start_command "/usr/bin/sv start /etc/service/nginx"
==> default:   stop_command "/usr/bin/sv stop /etc/service/nginx"
==> default:   status_command "/usr/bin/sv status /etc/service/nginx"
==> default:   restart_command "/usr/bin/sv restart /etc/service/nginx"
==> default:   reload_command "/usr/bin/sv hup /etc/service/nginx"
==> default:   startup_type :automatic
==> default:   cookbook_name :nginx
==> default:   recipe_name "source"
==> default: end
==> default:
==> default:
==> default:
==> default: [2015-03-25T20:59:52+00:00] DEBUG: Re-raising exception: Chef::Exceptions::MultipleFailures - Multiple failures occurred:
==> default: * Mixlib::ShellOut::ShellCommandFailed occurred in chef run: runit_service[nginx] (nginx::source line 124) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
==> default: ---- Begin output of /usr/bin/sv restart /etc/service/nginx ----
==> default: STDOUT: timeout: down: /etc/service/nginx: 1s, normally up, want up
==> default: STDERR:

It looks to me like the service doesn't have something it needs to start. It could also be related to the fact that I am stuck on chef 11.x for the time being. Thank you for your quick reply.

@gmccue
Copy link

gmccue commented Aug 27, 2015

@crmckenzie were you able to resolve this? It looks like you are using runit. If so, you can check the runit log within the Vagrant vm: /etc/sv/nginx/log/main/current by default.

@crmckenzie
Copy link
Author

I was never able to upgrade to 2.7.5 - I've punted on this question for the time being and am sticking with 2.7.4. I have something that works now with 2.7.4. Since I can't promise an ETA on a 2.7.x test I'd close this issue and rely on me to come back to it later.

Thanks for following up. :)

@aaronjensen
Copy link

This is broken for me as well. It doesn't appear to work out of the box for installing from source with runit. It's broken on 2.7.4 and 2.7.6 for us.

Recipe: nginx::source
  * service[nginx] action reload
    - reload service service[nginx]
  * service[nginx] action restart

    ================================================================================
    Error executing action `restart` on resource 'service[nginx]'
    ================================================================================

    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of /usr/bin/sv restart /etc/service/nginx ----
    STDOUT: timeout: down: /etc/service/nginx: 0s, normally up, want up
    STDERR:
    ---- End output of /usr/bin/sv restart /etc/service/nginx ----
    Ran /usr/bin/sv restart /etc/service/nginx returned 1

    Resource Declaration:
    ---------------------
    # In /home/vagrant/chef-solo/cookbooks-2/nginx/recipes/source.rb

    126:   service 'nginx' do
    127:     supports       :status => true, :restart => true, :reload => true
    128:     reload_command "#{node['runit']['sv_bin']} hup #{node['runit']['service_dir']}/nginx"
    129:   end
    130: when 'bluepill'

    Compiled Resource:
    ------------------
    # Declared in /home/vagrant/chef-solo/cookbooks-2/nginx/recipes/source.rb:126:in `from_file'

    service("nginx") do
      provider Chef::Provider::Service::Simple
      action "nothing"
      updated true
      supports {:status=>true, :restart=>true, :reload=>true}
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      service_name "nginx"
      running true
      pattern "nginx"
      start_command "/usr/bin/sv start /etc/service/nginx"
      stop_command "/usr/bin/sv stop /etc/service/nginx"
      status_command "/usr/bin/sv status /etc/service/nginx"
      restart_command "/usr/bin/sv restart /etc/service/nginx"
      reload_command "/usr/bin/sv hup /etc/service/nginx"
      declared_type :service
      cookbook_name :nginx
      recipe_name "source"
    end

@aaronjensen
Copy link

fwiw, I think it's broken for us because our nginx can't actually start until a deploy has happened, so it just spins trying to start. Probably an issue we should fix on our end...

@gmccue
Copy link

gmccue commented Sep 1, 2015

@aaronjensen looks like exactly the problem I had. Turns out the source recipe wasn't properly setting the nginx binary path so the service could not be started.

I submitted a PR that may help you:: #378 or you can use my modified branch:: https://github.com/ecosia/nginx/tree/master

@jklein
Copy link

jklein commented Sep 21, 2015

Same problem here, the fix from @gmccue worked for me.

@tas50
Copy link
Contributor

tas50 commented Sep 17, 2017

Thanks for opening this issue. Just today we merged the changes from the chef_nginx fork of this cookbook back to master here. It’s a pretty huge change set and includes over a year of active development that resulted in several major releases. I think there’s a very high chance that this issue has been resolved with that work and at this point I’m going to close this issue out. I’d encourage you to checkout the master branch and please open this issue back up if you’re still having the problem there.

Here’s the changes that were just merged in: #435

@tas50 tas50 closed this as completed Sep 17, 2017
@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants