Skip to content

Instantly share code, notes, and snippets.

@askrynnikov
askrynnikov / qna
Last active April 22, 2017 04:57
Config monit for qna
### Unicorn ###
check process unicorn
with pidfile "/home/deploy/qna/shared/tmp/pids/unicorn.pid"
start program = "/bin/su - deploy -c 'cd /home/deploy/qna/current && RAILS_ENV=production /home/deploy/.rbenv/bin/rbenv exec bundle exec unicorn -c /home/deploy/qna/current/config/unicorn/production.rb -E deployment -D'"
stop program = "/bin/su - deploy -c 'kill -s QUIT `cat /home/deploy/qna/current/tmp/pids/unicorn.pid`'"
if memory usage > 90% for 3 cycles then restart
if cpu usage > 90% for 2 cycles then restart
if 5 restarts within 5 cycles then timeout
### Nginx ###
require 'date'
require 'csv'
require 'ostruct'
def print_movies(movies)
movies.each { |movie| puts "#{movie[:title]} (#{movie[:date]}; #{movie[:genres].join("/")}) - #{movie[:duration]} min" }
end
def parse_date(date)