Search code examples
apacheamazon-web-servicesaws-opsworks

Chef on AMZ ami, restart fails with httpd is stopped Starting httpd: Address already in use


I'm implementing a chef script on an Amazon AMI image via ops works. My goal is to insert the httpd.conf and a conf.d/wa.conf to setup a site on port 8889. Then restart apache with the new configuration.

However, when I try to restart I get the following error:

STDOUT: Stopping httpd: [  OK  ] 
httpd is stopped
Starting httpd: [FAILED]
STDERR: (98)Address already in use: make_sock: could not bind to address 0.0.0.0:8889
no listening sockets available, shutting down
Unable to open logs
End output of     service httpd stop
---- 

I've tried a number of configurations, but all of them seem to fail. When I logon to the box after the config fails, port 8889 is not in use. I can start httpd by hand at that point, but it still fails.

Here is the chef script:

service 'httpd' do
  supports :status => true, :start => true, :stop => true, :restart => true
  action [:nothing]
end


template "/etc/httpd/conf/httpd.conf" do
  source 'httpd.conf.erb'
  action :create
  notifies :restart, 'service[httpd]'
end

I've tried a number of variations, but it always seems to start before the shutdown is complete maybe?

Any help would be greatly appreciated.

thanks.

myles.


Solution

  • For some reason port 8889 could not be used.

    I switched the server to a different port and it worked.