Mina Puma
Mina tasks for handle with Puma using systemd.
This gem provides several mina tasks:
mina puma:reload # Restart puma (using phased restart)
mina puma:restart # Restart puma (using stop, then start)
mina puma:start # Start puma
mina puma:stop # Stop puma
mina puma:status # Get status
Installation
Add this line to your application's Gemfile:
gem 'mina-puma-systemd', require: false
And then execute:
$ bundle
Note: by just including this gem, does not mean your development server will be Puma, for that, you need explicitly add gem 'puma'
to your Gemfile and configure it.
This gem does not (yet) create puma and systemd service config files, you have to do it manually.
Usage
Add this to your config/deploy.rb
file:
require 'mina/puma-systemd'
Make sure the following settings are set in your config/deploy.rb
:
deploy_to
- deployment pathrails_env
- rails environement (will default toproduction
)
Make sure the following directories exists on your server (they are added automatically to shared_dirs
:
shared/tmp/sockets
- directory for socket files.shared/tmp/pids
- directory for pid files.
You can tweak some settings:
puma_systemctl
- systemctl command, default issudo systemctl
. Other option would besystemctl --user
if you have setup pumas as user service.puma_service_name
- puma service name , default ispuma_#{fetch(:application_name)}_#{fetch(:puma_env)}
Then:
$ mina puma:start
Example
require 'mina/puma-systemd'
task :deploy do
deploy do
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
...
on :launch do
...
invoke :'puma:reload'
end
end
end
sudo configuration
By default plugin relies on sudo to run systemctl command. You should give proper permissions to the user which runs your app.
Cmnd_Alias SERVICES = /usr/bin/systemctl start *, /usr/bin/systemctl stop *, /usr/bin/systemctl reload *, /usr/bin/systemctl restart *, /usr/bin/systemctl status *, /usr/bin/systemctl enable *, /usr/bin/systemctl disable *
deploy ALL=(ALL) NOPASSWD: SERVICES
If you are paranoid, substitute *
with exact service name. Better option would be to run as user service, but it did not work for me out of box on AWS AMI2.
TODO
- Generate and upload puma.rb file
- Generate and upload puma systemd service
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request