Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
Added auto-start of nginx to setup phase. Resolves #15
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Rzegocki committed Apr 18, 2016
1 parent b8d8ff5 commit fbb07dc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 9 additions & 3 deletions libraries/drivers_webserver_nginx.rb
Expand Up @@ -15,6 +15,7 @@ def setup(context)
node.default['nginx']['install_method'] = out[:build_type].to_s == 'source' ? 'source' : 'package'
recipe = out[:build_type].to_s == 'source' ? 'source' : 'default'
context.include_recipe("nginx::#{recipe}")
define_service(context, :start)
end

def configure(context)
Expand All @@ -29,14 +30,19 @@ def configure(context)
end

def before_deploy(context)
context.service 'nginx' do
supports status: true, restart: true, reload: true
end
define_service(context)
end
alias before_undeploy before_deploy

private

def define_service(context, default_action = :nothing)
context.service 'nginx' do
supports status: true, restart: true, reload: true
action default_action
end
end

def add_ssl_directory(context)
context.directory '/etc/nginx/ssl' do
owner 'root'
Expand Down
4 changes: 4 additions & 0 deletions spec/unit/recipes/setup_spec.rb
Expand Up @@ -79,5 +79,9 @@
expect(chef_run).to install_package('git')
expect(chef_run).to install_package('libpq-dev')
end

it 'defines service which starts nginx' do
expect(chef_run).to start_service('nginx')
end
end
end

0 comments on commit fbb07dc

Please sign in to comment.