Repository is archived
No commit activity in last 3 years
No release in over 3 years
Helpers for capistrano recipes using runit/monit. Currently: capistrano-puma and capistrano-delayed_job
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.3.0
~> 1.8.6

Runtime

>= 2.15.5
 Project Readme

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