Coder Social home page Coder Social logo

capistrano-monit_runit's Introduction

Capistrano - Monit and Runit helpers

This libary is a helper library for capistrano tasks that setup runit and monit for various services.

Note: This has been updated to support Capistrano >= 3.4. If you still use Capistrano 2.x, see the capistrano2 branch

Not maintained!

This is no longer maintained, as deployment methods have changed the last years. (Kubernetes, docker, etc)

Versioning

Use 3.x for capistrano 3

For capistrano2, see the capistrano2 branch (will not be updated)

Usage

You are unlikely to require this library without any of the libraries depending on it.

But if you do require only Runit and Monit capistrano helpers, add this to your Gemfile in the development section.

gem 'capistrano-runit_monit', require: false

In your Capfile:

require 'capistrano/monit'
require 'capistrano/runit'

Roles:

capistrano-runit_monit targets :app and :worker roles by default.

Sudoing

You should setup sudoers to allow control over monit and runit from the deployment user in either Salt, puppet, chef or other form for infrastructure setup

The cap tasks for creating a sudoers list has been deprecated, as it does not belong to deployment of an app

Services for Monit and Runit

Services created:

It is fairly easy to create new service. Fork/clone either capistrano-puma or capistrano-delayed_job and create a new service based on either.

All services should have their own repository, as it makes it easier when deploying to choose what services you need for the application you are deploying.

Capistrano tasks

Tasks that work on your entire application and not just on a single service.

Note: The tasks will not work unless you have installed any monit services

Monit

All these tasks do monit tasks for all services setup with monit.

cap monit:disable               # Disable monit services for application
cap monit:enable                # Enable monit services for application
cap monit:main_config           # Setup main monit config file (/etc/monit/monitrc)
cap monit:monitor               # Monitor the application
cap monit:purge                 # Purge/remove all monit configurations for the application
cap monit:reload                # Reload monit config (global)
cap monit:restart               # Restart monitoring the application
cap monit:setup                 # Setup monit folders and configuration
cap monit:start                 # Start monitoring the application permanent (Monit saves state)
cap monit:status                # Status monit (global)
cap monit:stop                  # Stop monitoring the application permanent (Monit saves state)

Setup in your deploy file

You can add this to deploy.rb or env.rb in order to automatically monitor/unmonitor tasks

It is important to unmonitor tasks while deploying as they can trigger stops/restarts to the app that monit thinks are "crashes"

before 'deploy:updating', 'monit:unmonitor'
after 'deploy:finished', 'monit:monitor'

If you want monit to automatically start/stop runit instead of triggering seperately

before "monit:unmonitor", "monit:stop"
after  "monit:monitor",   "monit:start"

Runit

All these tasks do runit tasks for all services setup with runit.

cap runit:disable               # Disable runit services for application
cap runit:enable                # Enable runit services for application
cap runit:once                  # Only start services once.
cap runit:purge                 # Purge/remove all runit configurations for the application
cap runit:setup                 # Setup runit for the application
cap runit:start                 # Start all runit services for current application
cap runit:stop                  # Stop all runit services for current application

Setup in your deploy file

You can add this to deploy.rb or env.rb in order to automatically start/stop tasks

before "deploy:updating", "runit:stop"
after  "deploy:finished", "runit:start"

Or just before finishing the update:

before "deploy:finished", "runit:stop"
after  "deploy:finished", "runit:start"

See each gem if you want to start/stop each service separate instead of together.

Assumptions

There are some assumptions when using this with capistrano. The following variables must be set

  • :application - The application name
  • :user - The username which is running the deployed application (usually deploy..)
  • :group - The groupname which is running the deployed application (usually deploy..)

Contributing

  • Fork the project
  • Make a feature addition or bug fix
  • Please test the feature or bug fix, or write tests for it
  • Make a pull request

Copyright

(c) 2013-2015 Leif Ringstad. See LICENSE.txt for details

capistrano-monit_runit's People

Contributors

leifcr avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

qbrossard

capistrano-monit_runit's Issues

finish: line 87: test: -gt: unary operator expected

Finish script triggers this on ubuntu 12.04
finish: line 87: test: -gt: unary operator expected
finish: line 120: test: -gt: unary operator expected

Should be solved by adding " around the variable on the given line.

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.