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

Wait for Monit to be reloaded #170

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ivanovaleksey
Copy link

@ivanovaleksey ivanovaleksey commented Apr 11, 2017

Hi @seuros.

I just started to use Monit.
I noticed that there is task sidekiq:monit:config which is called when there is no process to monitor.
The task reloads Monit which is fine but it seems like Monit doesn't have enough time to fully reload.
That is why I have the following error:

00:14 sidekiq:monit:monitor
      01 sudo /usr/bin/monit monitor sidekiq_orip_bot_staging0
      01 [sudo] password for deployer:
      01
      01 There is no service named "sidekiq_orip_bot_staging0"
      01
00:15 sidekiq:monit:config
      Uploading /tmp/monit.conf 100.0%
      01 sudo mv /tmp/monit.conf /etc/monit/conf.d/sidekiq_orip_bot_staging.conf
      01 [sudo] password for deployer:
      01
    ✔ 01 [email protected] 0.050s
      02 sudo /usr/bin/monit reload
      02 [sudo] password for deployer:
      02
      02 Reinitializing monit daemon
    ✔ 02 [email protected] 0.060s
      03 sudo /usr/bin/monit monitor sidekiq_orip_bot_staging0
      03 [sudo] password for deployer:
      03
      03 There is no service named "sidekiq_orip_bot_staging0"
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: sudo exit status: 1
sudo stdout: [sudo] password for deployer:
There is no service named "sidekiq_orip_bot_staging0"
sudo stderr: Nothing written

SSHKit::Command::Failed: sudo exit status: 1
sudo stdout: [sudo] password for deployer:
There is no service named "sidekiq_orip_bot_staging0"
sudo stderr: Nothing written

SSHKit::Command::Failed: sudo exit status: 1
sudo stdout: [sudo] password for deployer:
There is no service named "sidekiq_orip_bot_staging0"
sudo stderr: Nothing written

Tasks: TOP => sidekiq:monit:monitor
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as [email protected]: sudo exit status: 1
sudo stdout: [sudo] password for deployer:
There is no service named "sidekiq_orip_bot_staging0"
sudo stderr: Nothing written

With this little sleep 1 Monit is getting reloaded and I have no error.
The solution seems to be dirty but it works...

What do you think?

P. S.
The same thing happens in capistrano3-puma gem.
If the solution is suitable I would provide the same PR for capistrano3-puma too.

@gregawoods
Copy link

We run into this frequently. I've come to where I expect that the first deploy of an app with sidekiq/monit will generally fail, and deploying a second time will succeed.

Admittedly a sleep 1 is not ideal, as we don't always know how much time monit will require to have reloaded. But it's still better than dealing with unnecessary deploy failures, IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants