![]() Stop program = “/bin/su - deploy /bin/bash -c ‘cd /var/www/production/current bundle exec rpush stop -e production -p /var/www/production/shared/pids/rpush.pid’” Start program = “/bin/su - deploy /bin/bash -c ‘cd /var/www/production/current bundle exec rpush start -e production -p /var/www/production/shared/pids/rpush.pid’” As you might have guessed, we use Monit to control Rpush as well:Ĭheck process production_rpush with pidfile /var/www/production/shared/pids/rpush.pid Basically, it’s a gem that allows for sending notifications to mobile devices. ![]() Mainly, we use Rpush as a notifications service for some web applications. In this case, it’s a useful option since there are multiple processes (Sidekiq, Puma, Rpush) that we need to restart with only one command right after deploy. Now all the processes controlled by Monit and containing the ”group production_ruby“ line can be restarted by “monit -g production_ruby restart all”. You might also have noticed group which gives us the ability to control the process by querying the group. We send the start and stop commands as we would normally do this in the console. You can see that Monit is monitoring the state of the process based on the PID file. In this example, we are doing pretty much the same as in the Sidekiq part. Stop program “/bin/su - deploy -c ‘cd /var/www/production/current & /usr/local/rbenv/bin/rbenv exec bundle exec pumactl -S /var/www/production/shared/pids/puma.state stop’” Start program “/bin/su - deploy -c ‘cd /var/www/production/current & /usr/local/rbenv/bin/rbenv exec bundle exec puma -C /var/www/production/shared/config/puma.rb’” We use Monit to monitor and manage Puma through this config:Ĭheck process puma_production with pidfile “/var/www/production/shared/pids/puma.pid” Puma is a web server for Ruby applications. In the code above, we tell Monit that it needs to execute the command with user “deploy” and that will start the process. This applies to Nginx or any other simple system process, but if there are some Rails application components, you need to specify how the process will start in detail. Start program = “command_to_execute_to_start_the_process” stop program = “command_to_execute_to_stop_the_process” But what will happen if you start/stop it through Monit? If you save the changes and reload Monit now, it will grab the process and tell you if it’s running or not. What we do here is tell Monit that there is a Sidekiq instance running and then specify the PID file location.Ĭheck process name_of_the_process with pidfile “location_of_the_pid_file” If totalmem is greater than 400 MB for 2 cycles then restart if does not exist then alert Stop program = “/bin/su - deploy ‘cd /home/deploy/apps/ & bundle exec sidekiqctl stop /home/deploy/apps//tmp/pids/sidekiq-0.pid’” with timeout 90 seconds Start program = “/bin/su - deploy -c ‘cd /home/deploy/apps/ & bundle exec sidekiq -e staging -C /home/deploy/apps//config/sidekiq.yml -P /home/deploy/apps//tmp/pids/sidekiq-0.pid -L /home/deploy/apps//log/sidekiq.log -d’” with timeout 90 seconds Why? It is very flexible and enables you to do the same thing in several ways through a config file:Ĭheck process sidekiq with pidfile “/home/deploy/apps//tmp/pids/sidekiq-0.pid” We also use Monit to control and monitor Sidekiq state. Sidekiq is a background processing framework for Ruby. We will show you how to set up each of them starting from nginx. In commercial projects development, we use Monit to monitor and/or control services like Sidekiq, ElasticSearch, Redis server, Rpush, Nginx, PostgreSQL, and some others. Set mailserver some_mail_server Monit configuration and setup If the first one fails, Monit will move to the second one and so on. Further, you can specify several mail servers that will be used to deliver alerts. To enable this option you need to change few lines in the main configuration file.īy default, Monit uses local host for sending emails. If you want to always have the latest updates on the monitored processes - just enable alerts and Monit will start sending emails to a specified address should any errors occur. The port address can also be changed to a custom one if security is a top priority. After the web interface has been configured it can be accessed by this link.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |