No commit activity in last 3 years
No release in over 3 years
Capistrano tasks for automatic and sensible unicorn configuration Work *only* with Capistrano 3+ Enable Zero downtime deployments of rails application. Support for Ubuntu server and Centos, EC2... server same fedora, . This gem customize from https://github.com/bruno-/capistrano-unicorn-nginx
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0

Runtime

~> 1.2
 Project Readme

Capistrano::SimpleUnicorn

Support for Capistrano 3.x

Capistrano task for automatic and unicorn configuration

This gem customize from capistrano-unicorn-nginx, and support for Ubuntu server, CentOs server, EC2 server...

Highlight of Gem:

  • Automatic config unicorn for rails app
  • Zero downtime deployments enabled

Installation

Add this to Gemfile:

group :development do
    gem "capistrano"
    gem "capistrano-simple-unicorn"
end

And then:

$ bundle install

Setup and usage

  1. Update Capfile
require "capistrano/simple_unicorn"
  1. Run deploy
$ bundle exec cap production deploy

configuration

Default value:

set :unicorn_service, -> { "unicorn_#{fetch(:application)}" }
set :user_home_path, -> { "/home/#{fetch(:user)}" }
set :unicorn_config_file, -> { shared_path.join("config", "unicorn.rb") }
set :unicorn_pid_file, -> { shared_path.join("tmp", "pids", "unicorn.pid") }
set :unicorn_sock_file, -> { shared_path.join("tmp", "unicorn.sock") }
set :unicorn_log_file, -> { shaed_path.join("log", "unicorn.stdout.log") }
set :unicorn_error_log_file, -> {shared_path.join("log","unicorn.stderr.log")}
set :ruby_version, -> { fetch(:rvm_ruby_version) || fetch(:rbenv_ruby) }
set :unicorn_worker_processes, 2
set :unicorn_timeout, 30

If you want to change config: Example

# in config/deploy/production.rb
set :unicorn_worker_processes, 4
set :unicorn_timeout, 60

scrip remote

  • start|stop|restart unicron, run:
$ cap production unicorn:start
$ cap production unicorn:stop
$ cap production unicorn:restart

Config nginx

  • Generate file config nginx, run:
$ cap production nginx:setup
  • start|stop|restart nginx, run:
$ cap production nginx:start
$ cap production nginx:stop
$ cap production nginx:restart

You need add directory to sock file of app. Example using unicorn for app:

# in config/deploy.rb
set :nginx_upstream_file, "/tmp/unicorn.sock"

Default config

    set :nginx_listen_port, 80 #listen_port
    set :nginx_server_name, "_" #server_name
    set :nginx_upstream_name, -> { "#{fetch(:application)}" } # upstream name
    set :nginx_config_name, -> { "#{fetch(:application)}_#{fetch(:stage)}" } #file name config
    set :nginx_fail_timeout, 0
    set :nginx_access_log_file, -> { "/var/log/nginx/#{fetch(:nginx_config_name)}.access.log" } # access log file
    set :nginx_error_log_file, -> { "/var/log/nginx/#{fetch(:nginx_config_name)}.error.log" } # error log file
    set :nginx_upstream_file, -> { "#{fetch(:unicorn_sock_file)}" } # .sock file path