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

Commit

Permalink
fix: run monit reload only once, after configure hook
Browse files Browse the repository at this point in the history
Fixes #251
  • Loading branch information
kzkn authored and ajgon committed Feb 7, 2021
1 parent 22a6ef0 commit 1b784d1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 0 additions & 2 deletions libraries/drivers_appserver_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ def add_appserver_monit
source 'appserver.monitrc.erb'
variables opts
end

context.execute 'monit reload'
end

def restart_monit
Expand Down
2 changes: 0 additions & 2 deletions libraries/drivers_worker_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ def add_worker_monit
cookbook opts[:source_cookbook].to_s
variables opts
end

context.execute 'monit reload'
end

def worker_monit_template_cookbook
Expand Down
4 changes: 4 additions & 0 deletions recipes/configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@
webserver = Drivers::Webserver::Factory.build(self, application)

fire_hook(:configure, items: databases + [source, framework, appserver, worker, webserver])

execute 'monit reload' do
only_if 'which monit'
end
end
6 changes: 6 additions & 0 deletions spec/unit/recipes/configure_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
let(:chef_run_rhel) do
chef_runner_rhel.converge(described_recipe)
end
let(:monit_installed) { false }
before do
stub_search(:aws_opsworks_app, '*:*').and_return([aws_opsworks_app])
stub_search(:aws_opsworks_rds_db_instance, '*:*').and_return([aws_opsworks_rds_db_instance])
stub_command('which monit').and_return(monit_installed)
end

context 'context savvy' do
Expand Down Expand Up @@ -65,6 +67,8 @@
end

context 'Postgresql + Git + Unicorn + Nginx + Rails + Sidekiq' do
let(:monit_installed) { true }

it 'creates proper database.yml template with connection options' do
db_config = Drivers::Db::Postgresql.new(chef_run, aws_opsworks_app, rds: aws_opsworks_rds_db_instance).out
expect(db_config[:adapter]).to eq 'postgresql'
Expand Down Expand Up @@ -502,6 +506,7 @@
solo_node.set['deploy'] = deploy
end.converge(described_recipe)
end
let(:monit_installed) { true }

before do
stub_search(:aws_opsworks_rds_db_instance, '*:*').and_return([aws_opsworks_rds_db_instance(engine: 'mysql')])
Expand Down Expand Up @@ -1023,6 +1028,7 @@
solo_node.set['nginx'] = node['nginx']
end.converge(described_recipe)
end
let(:monit_installed) { true }

before do
stub_search(:aws_opsworks_app, '*:*').and_return([aws_opsworks_app(data_sources: [])])
Expand Down
6 changes: 6 additions & 0 deletions spec/unit/recipes/deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
let(:chef_run_rhel) do
chef_runner_rhel.converge(described_recipe)
end
let(:monit_installed) { false }
before do
stub_search(:aws_opsworks_app, '*:*').and_return([aws_opsworks_app])
stub_search(:aws_opsworks_rds_db_instance, '*:*').and_return([aws_opsworks_rds_db_instance])
stub_command('which monit').and_return(monit_installed)
end

it 'includes recipes' do
Expand Down Expand Up @@ -69,6 +71,8 @@
end

context 'Postgresql + Git + Unicorn + Nginx + Sidekiq' do
let(:monit_installed) { true }

it 'creates git wrapper script' do
expect(chef_run).to create_template('/tmp/ssh-git-wrapper.sh')
end
Expand Down Expand Up @@ -204,6 +208,7 @@
solo_node.set['deploy'] = deploy
end
end
let(:monit_installed) { true }
let(:tmpdir) { '/tmp/opsworks_ruby' }

before do
Expand Down Expand Up @@ -289,6 +294,7 @@
solo_node.set['deploy'] = deploy
end
end
let(:monit_installed) { true }
let(:tmpdir) { '/tmp/opsworks_ruby' }

before do
Expand Down

0 comments on commit 1b784d1

Please sign in to comment.