-
Notifications
You must be signed in to change notification settings - Fork 0
Monit Configuration
Robin Miller edited this page Sep 19, 2022
·
5 revisions
Here is a Monit config file guideline template. This is heavily dependent on your situation, so you're on your own to figure the details out.
- Replace the references to
my-app
with your app name. Use only alphanumerics, dash, and underscore. - The pidfile must perfectly match the path defined in your rake task, or else you will get a Monit status of
Execution failed | Does not exist
- You may want to change the
uid
and/orgid
to a more general user/group likewww-data
if you are not using the recommended one-user-per-application style. - Debian-family distributions (Ubuntu, PopOS, Mint, Debian, etc), keep Monit application config files in
/etc/monit/conf-available/
with a symlink to it in/etc/monit/conf-enabled/
. - This is using
bash --login
to cause chruby to be loaded. If you do not use chruby, you may be able to simplify this step, but will need to provide absolute paths to everything. - You can alternatively replace the start/stop commands with a path to custom-written shell script. This may be necessary/better if you need to set environment variables.
/etc/monit/conf-available/procrastinator-my-app.conf
# =======================================
# Monit Config File
# =======================================
#
# See: https://mmonit.com/monit/documentation/monit.html
##
# Watches the process ID file and controls the process with that ID.
check process procrastinator-my-app
with pidfile /tmp/procrastinator-my-app.pid
# Start and stop use --login to load normal path, chruby, etc.
start = "/bin/bash --login -c 'cd /var/www/my-app && bundle exec rake procrastinator:start'"
with uid 'my-app'
with gid 'my-app'
stop = "/bin/bash --login -c 'cd /var/www/my-app && bundle exec rake procrastinator:stop'"
# These are Monit groupings, not posix user groups.
group procrastinator
group my-app
- Make sure the pid file matches
- Make sure the uid that runs the daemon has permissions to access all the code, bundle, and bundle config used in the task.
- This can show up as bundler load errors where it cannot find a required gem but it is installed.
- Possibly helpful bash command:
find /var/www/my-app/* -not -user my-app
- Check the /var/log/monit.log file for errrors.
- Check the procrastinator.log file for errors (usually in your application directory ./log/)