-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.monitrc
23 lines (19 loc) · 1.13 KB
/
.monitrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# .monitrc
# Inspired from:
# https://www.monterail.com/blog/2015/deployment-setup-for-jruby-rails-app-with-puma-mina-and-monit
# Logs
set logfile /home/user/monit.log
# Pidfile
set pidfile /home/user/.monit.pid
# Run Monit as daemon, waking up every 60 seconds
set daemon 60
check process app-puma
with pidfile /home/user/appname/shared/tmp/pids/puma.pid
start program = "/usr/bin/nohup /bin/bash -c 'cd /home/user/appname/current; PATH=$PATH:/usr/local/bin:/home/user/.rbenv/bin:/home/user/.rbenv/shims RAILS_ENV=staging bundle exec puma -C config/puma/staging.rb >/home/user/appname/shared/tmp/puma.out 2>/home/user/appname/shared/tmp/puma.err </dev/null' &"
stop program = "/bin/bash -c 'cd /home/user/appname && if [ -f shared/tmp/pids/puma.pid ]; then cat shared/tmp/pids/puma.pid && echo 'STOP' | xargs kill -9; rm shared/tmp/pids/puma.pid; fi'"
if totalmem > 300.0 MB for 5 cycles then restart
if cpu usage > 95% for 5 cycles then restart
group app
check file app-restart with path /home/user/appname/shared/tmp/restart.txt
if changed timestamp
then exec "/bin/bash -c 'kill -12 `cat /home/user/appname/shared/tmp/pids/puma.pid`'"