Base core capistrano3 module for managing various services via runit supervisor.
Add to Gemfile
:
group :development do
gem "capistrano-runit-core", "~> 0.1.0"
end
Run:
$ bundle install
We need to create specific runit service for our whole application:
Create service folder inside /etc/sv
:
mkdir /etc/sv/runsvdir-your_application
mkdir /etc/sv/runsvdir-your_application/log
Create run shell script /etc/sv/runsvdir-your_application/run
:
#!/bin/sh
exec 2>&1
exec chpst -udeployer:deployer -e /home/deployer/apps/your_application/runit/.env runsvdir /home/deployer/apps/your_application/runit/enabled
In current example expected what you deploying with deployer
user to the /home/deployer/apps/your_application
folder.
Create log run shell script /etc/sv/runsvdir-your_application/log/run
:
#!/bin/sh
exec svlogd -tt /var/log/runsvdir-your_application
Create log folder:
mkdir /var/log/runsvdir-your_application
And make this scripts executable:
chmod a+x /etc/sv/runsvdir-your_application/run /etc/sv/runsvdir-your_application/log/run
And after this we will need to make symlink in /etc/service/
ln -s /etc/sv/runsvdir-your_application /etc/service/runsvdir-your_application
Add this line in Capfile
:
require "capistrano/runit"
runit:setup
-- prepare runit directories in the project directory.
runit_roles
-- what host roles uses runit to run processes. Default value:[:app, :db]
.runit_sv_search_path
-- Path of $PATH where we will try to found sv binary. Default value:/sbin:/usr/sbin