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

Commit

Permalink
Fixed appserver restart sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Rzegocki committed Apr 16, 2016
1 parent 1581def commit 9a75f9c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
19 changes: 18 additions & 1 deletion libraries/drivers_appserver_unicorn.rb
Expand Up @@ -7,7 +7,7 @@ class Unicorn < Drivers::Appserver::Base
output filter: [
:accept_filter, :backlog, :delay, :preload_app, :tcp_nodelay, :tcp_nopush, :tries, :timeout, :worker_processes
]
notifies action: :restart,
notifies action: :start,
resource: proc { |app| "service[unicorn_#{app['shortname']}]" },
timer: :immediately

Expand All @@ -17,8 +17,25 @@ def configure(context)
add_unicorn_service_context(context)
end

def before_deploy(context)
manual_action(context, :stop)
end

def after_deploy(context)
manual_action(context, :start)
end

private

def manual_action(context, action)
deploy_to = deploy_dir(app)
service_script = File.join(deploy_to, File.join('shared', 'scripts', 'unicorn.service'))

context.execute "#{action} unicorn" do
command "#{service_script} #{action}"
end
end

def add_unicorn_config(context)
deploy_to = deploy_dir(app)
environment = app['environment']
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/recipes/deploy_spec.rb
Expand Up @@ -35,16 +35,16 @@
end

it 'performs a deploy' do
deploy = chef_run.deploy(aws_opsworks_app['shortname'])

expect(chef_run).to deploy_deploy('dummy_project').with(
repository: 'git@git.example.com:repo/project.git',
revision: 'master',
scm_provider: Chef::Provider::Git,
enable_submodules: false,
ssh_wrapper: '/tmp/ssh-git-wrapper.sh'
)
expect(deploy).to notify("service[unicorn_#{aws_opsworks_app['shortname']}]").to(:restart).immediately

expect(chef_run).to run_execute('stop unicorn')
expect(chef_run).to run_execute('start unicorn')
end
end
end

0 comments on commit 9a75f9c

Please sign in to comment.