Skip to content

Instantly share code, notes, and snippets.

@IgorShayderov
Last active September 2, 2020 17:24
Show Gist options
  • Select an option

  • Save IgorShayderov/b86ec1be2e9db9565b9b7b1739cdcd22 to your computer and use it in GitHub Desktop.

Select an option

Save IgorShayderov/b86ec1be2e9db9565b9b7b1739cdcd22 to your computer and use it in GitHub Desktop.

Revisions

  1. IgorShayderov revised this gist Sep 2, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Monit config
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ check process nginx with pidfile /run/nginx.pid
    if cpu > 60% for 2 cycles then alert
    if cpu > 80% for 5 cycles then restart
    if memory usage > 80% for 5 cycles then restart
    if failed host 188.166.44.84 port 80 protocol http
    if failed host 79.143.30.92 port 80 protocol http
    then restart
    if 3 restarts within 5 cycles then timeout

  2. IgorShayderov revised this gist Sep 1, 2020. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions Monit config
    Original file line number Diff line number Diff line change
    @@ -51,8 +51,9 @@ check process unicorn
    ### Sphinx ###
    check process sphinx
    with pidfile "/home/deploy/qna/shared/log/production.sphinx.pid"
    start program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && /home/deployer/.rvm/bin/rvm default do bundle exec rake ts:start'"
    stop program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && /home/deployer/.rvm/bin/rvm default do bundle exec rake ts:stop'"
    start program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && /home/deployer/.rvm/bin/rvm default do bundle exec rake RAILS_ENV=production ts:start'"
    stop program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && /home/deployer/.rvm/bin/rvm default do bundle exec rake RAILS_ENV=production ts:stop'"
    if cpu usage > 80% for 2 cycles then restart
    if memory usage > 80% for 4 cycles then restart


  3. IgorShayderov created this gist Sep 1, 2020.
    58 changes: 58 additions & 0 deletions Monit config
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    ### Nginx ###
    check process nginx with pidfile /run/nginx.pid
    start program = "/usr/sbin/service nginx start"
    stop program = "/usr/sbin/service nginx stop"
    if cpu > 60% for 2 cycles then alert
    if cpu > 80% for 5 cycles then restart
    if memory usage > 80% for 5 cycles then restart
    if failed host 188.166.44.84 port 80 protocol http
    then restart
    if 3 restarts within 5 cycles then timeout

    ### Postgresql ###
    check process postgresql
    with pidfile /var/run/postgresql/12-main.pid
    start program = "/usr/sbin/service postgresql start"
    stop program = "/usr/sbin/service postgresql stop"
    if failed host localhost port 5432 protocol pgsql then restart
    if cpu > 80% then restart
    if memory usage > 80% for 2 cycles then restart
    if 5 restarts within 5 cycles then timeout

    ### Redis ###
    check process redis-server
    with pidfile "/var/run/redis/redis-server.pid"
    start program = "/usr/sbin/service redis start"
    stop program = "/usr/sbin/service redis stop"
    if totalmem > 100 Mb then alert
    if children > 255 for 5 cycles then stop
    if cpu usage > 95% for 3 cycles then restart
    if memory usage > 80% for 5 cycles then restart
    if failed host 127.0.0.1 port 6379 then restart
    if 5 restarts within 5 cycles then timeout

    ### Sidekiq ###
    check process sidekiq
    with pidfile "/home/deployer/qna/shared/tmp/pids/sidekiq-0.pid"
    start program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && /home/deployer/.rvm/bin/rvm default do bundle exec sidekiq --index 0 --pidfile /ho>
    stop program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && /home/deployer/.rvm/bin/rvm default do bundle exec sidekiqctl stop /home/deployer/q>
    if cpu usage > 80% then restart
    if memory usage > 80% for 2 cycles then restart
    if 3 restarts within 3 cycles then timeout

    ### Unicorn ###
    check process unicorn
    with pidfile "/home/deployer/qna/shared/tmp/pids/unicorn.pid"
    start program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && /home/deployer/.rvm/bin/rvm default do bundle exec unicorn -c /home/deployer/qna/c>
    stop program = "/bin/kill -s QUIT `cat /home/deployer/qna/shared/tmp/pids/unicorn.pid`"
    if memory usage > 90% for 3 cycles then restart
    if cpu usage > 90% for 2 cycles then restart

    ### Sphinx ###
    check process sphinx
    with pidfile "/home/deploy/qna/shared/log/production.sphinx.pid"
    start program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && /home/deployer/.rvm/bin/rvm default do bundle exec rake ts:start'"
    stop program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && /home/deployer/.rvm/bin/rvm default do bundle exec rake ts:stop'"
    if cpu usage > 80% for 2 cycles then restart
    if memory usage > 80% for 4 cycles then restart