Commit 982b9ef4915c97a77e1b9e07b511803d4571ab61

Authored by Andrei Gliga
1 parent 26f97aea
Exists in master

how to configure monit for errbit on a capistrano deployment

Showing 1 changed file with 44 additions and 0 deletions   Show diff stats
docs/deployment/capistrano.md
... ... @@ -76,3 +76,47 @@ rbenv=1 bundle exec cap production deploy
76 76 ## Schedule recurring tasks
77 77 You may want to periodically clear resolved errors to free up space.
78 78 Schedule ```rake errbit:db:clear_resolved``` to run every day or so.
  79 +
  80 +
  81 +## Monit
  82 +If you like errbit to be monitored by monit, you'll have to install and start monit
  83 +with http support before deploying errbit.
  84 +In order to enable http support you have to edit the monit config file which you can
  85 +find in `/etc/monit/monitrc` for Ubuntu and set these lines:
  86 +```
  87 +set httpd port 2812 and
  88 + use address localhost # only accept connection from localhost
  89 + allow localhost
  90 +```
  91 +
  92 +Next you have to add the following line to the Capfile:
  93 +```
  94 +require 'capistrano/puma/monit'
  95 +```
  96 +
  97 +And you have to deploy the monit config with the command:
  98 +```bash
  99 +bundle exec cap production puma:monit:config
  100 +```
  101 +
  102 +The configuration file (depending on the distro) will be generated at: `/etc/monit/conf.d/puma_errbit_production.conf`
  103 +
  104 +### Controlling memory usage with monit
  105 +If you like to limit memory usage for puma and restart it in case the usage gets
  106 +over a 2GB limit, for example, you can add at the end of the monit config file the line
  107 +```
  108 +if totalmem is greater than 2048 MB for 3 cycles then restart
  109 +```
  110 +
  111 +The config file will look like:
  112 +
  113 +```
  114 +# Monit configuration for Puma
  115 +# Service name: puma_errbit_production
  116 +#
  117 +check process puma_errbit_production
  118 + with pidfile "/var/www/apps/errbit/shared/tmp/pids/puma.pid"
  119 + start program = "/usr/bin/sudo -u root /bin/bash -c 'cd /var/www/apps/errbit/current && /usr/bin/env bundle exec puma -C /var/www/apps/errbit/shared/puma.rb --daemon'"
  120 + stop program = "/usr/bin/sudo -u root /bin/bash -c 'cd /var/www/apps/errbit/current && /usr/bin/env bundle exec pumactl -S /var/www/apps/errbit/shared/tmp/pids/puma.state stop'"
  121 + if totalmem is greater than 2048 MB for 3 cycles then restart
  122 +```
... ...