GithubHelp home page GithubHelp logo

zhaozijie / capistrano-monit-recipes Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lgmkr/capistrano-monit-recipes

0.0 2.0 0.0 94 KB

Recipes for deploying Monit with Capistrano

License: MIT License

Ruby 100.00%

capistrano-monit-recipes's Introduction

Capistrano::Monit

Note: this plugin works only with Capistrano 3.

Recipes for deploying Monit with Capistrano

Plase check the capistrano gem version you're using before installing this gem: $ bundle show | grep capistrano

About

Capistrano Monit plugin allow you to generate a simple config file for Monit, and various config files for monitored processes, such as Nginx, Postgresql and Unicorn (soon Sidekiq too).

Here are the specific things this plugin does for your capistrano deployment process:

  • creates a config file for Monit
  • creates process config files for Nginx, Postgresql and Unicorn

Installation

Put the following in your application's Gemfile:

group :development do
  gem 'capistrano', '~> 3.1'
  gem 'capistrano-monit-recipes', github: 'louishouette/capistrano-monit-recipes'
end

Then:

$ bundle install

Usage

If you're deploying a standard rails app, all you need to do is put the following in Capfile file:

require 'capistrano-monit-recipes'

Make sure the deploy_to path exists and has the right privileges on the server (i.e. /home/deploy/apps).
Or just install capistrano-safe-deploy-to plugin and don't think about it.

To setup the server, run:

$ bundle exec cap production setup

Easy, right?

Check below to see what happens in the background.

Configuration

Put all your configs in capistrano stage or deploy files i.e: config/deploy/production.rb
config/deploy.rb

Here's the list of options and the defaults for each option:

set :monit_configure_nginx, false
set :monit_configure_postgresql, false
set :monit_configure_unicorn, false
set :monit_templates_path, 'config/deploy/templates'
set :monitrc_path, '/etc/monit/monitrc'    

# UNICORN TEMPLATE specific settings
set :monit_unicorn_process_name, -> { "unicorn_#{fetch(:application)}_#{fetch(:stage)}" }
set :monit_unicorn_pid, shared_path.join("tmp/pids/unicorn.pid")
set :monit_unicorn_service_name, -> { "unicorn_#{fetch(:application)}_#{fetch(:stage)}" }
set :monit_unicorn_workers_number, 2
set :monit_unicorn_worker_process_name, -> { "#{fetch(:application)}_#{fetch(:stage)}_unicorn_worker_" }
set :monit_alert_email, nil

# NGINX TEMPLATE specific settings
set :monit_nginx_pid, '/var/run/nginx.pid'

# POSTGRESQL TEMPLATE specific settings
set :monit_postgresql_pid, '/var/run/postgresql/9.3-main.pid'

# MONIT TEMPLATE specific settings
set :monit_gmail_username, nil
set :monit_gmail_password, nil
set :monit_alert_email, nil
set :monit_password, nil
set :monit_port, '2812'

Customizing the templates

If for any reason you want to edit or tweak the templates, you can copy them to config/deploy/templates/*.erb with this command:

$ bundle exec rails g capistrano:monit:template

After you edit the newly created files in your repo, they will be used as templates on the server.

More Capistrano automation?

If you'd like to streamline your Capistrano deploys, you might want to check these zero-configuration, plug-n-play plugins:

Contributing and bug reports

Contributions and improvements are very welcome. Just open a pull request and I'll look it up shortly.

If something is not working for you, or you find a bug please report it.

Thanks

This is my first gem, and even this README is eavily inspired from Bruno Sutic work. I use his capistrano gems on a daily basis, they're worth it! So thanks dude!

License

MIT

capistrano-monit-recipes's People

Contributors

louishouette avatar zhaozijie avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.