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

Add an option to disable monit configuration #188

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Configurable options, shown here with defaults:
:sidekiq_options => nil
:sidekiq_require => nil
:sidekiq_tag => nil
:sidekiq_config => nil # if you have a config/sidekiq.yml, do not forget to set this.
:sidekiq_config => nil # if you have a config/sidekiq.yml, do not forget to set this.
:sidekiq_queue => nil
:sidekiq_timeout => 10
:sidekiq_roles => :app
Expand All @@ -49,6 +49,7 @@ Configurable options, shown here with defaults:
:sidekiq_monit_templates_path => 'config/deploy/templates'
:sidekiq_monit_conf_dir => '/etc/monit/conf.d'
:sidekiq_monit_use_sudo => true
:sidekiq_monit_configure => true
:monit_bin => '/usr/bin/monit'
:sidekiq_monit_default_hooks => true
:sidekiq_monit_group => nil
Expand Down Expand Up @@ -134,6 +135,12 @@ If your deploy user has no need in `sudo` for using monit, you can disable it as
set :sidekiq_monit_use_sudo, false
```

If monit is already configured on the server, then you can disable the
configuration from the gem

```ruby
set :sidekiq_monit_configure, false
```
## Contributing

1. Fork it
Expand Down
15 changes: 9 additions & 6 deletions lib/capistrano/tasks/monit.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace :load do
set :sidekiq_monit_conf_dir, '/etc/monit/conf.d'
set :sidekiq_monit_conf_file, "#{sidekiq_service_name}.conf"
set :sidekiq_monit_use_sudo, true
set :sidekiq_monit_configure, true
set :monit_bin, '/usr/bin/monit'
set :sidekiq_monit_default_hooks, true
set :sidekiq_monit_templates_path, 'config/deploy/templates'
Expand All @@ -28,14 +29,16 @@ namespace :sidekiq do

desc 'Config Sidekiq monit-service'
task :config do
on roles(fetch(:sidekiq_roles)) do |role|
@role = role
upload_sidekiq_template 'sidekiq_monit', "#{fetch(:tmp_dir)}/monit.conf", @role
if fetch(:sidekiq_monit_configure)
on roles(fetch(:sidekiq_roles)) do |role|
@role = role
upload_sidekiq_template 'sidekiq_monit', "#{fetch(:tmp_dir)}/monit.conf", @role

mv_command = "mv #{fetch(:tmp_dir)}/monit.conf #{fetch(:sidekiq_monit_conf_dir)}/#{fetch(:sidekiq_monit_conf_file)}"
sudo_if_needed mv_command
mv_command = "mv #{fetch(:tmp_dir)}/monit.conf #{fetch(:sidekiq_monit_conf_dir)}/#{fetch(:sidekiq_monit_conf_file)}"
sudo_if_needed mv_command

sudo_if_needed "#{fetch(:monit_bin)} reload"
sudo_if_needed "#{fetch(:monit_bin)} reload"
end
end
end

Expand Down