Skip to content

Instantly share code, notes, and snippets.

@alexsergeyev
Created April 16, 2015 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexsergeyev/627a6b02a5622238a081 to your computer and use it in GitHub Desktop.
Save alexsergeyev/627a6b02a5622238a081 to your computer and use it in GitHub Desktop.
rails4_capistrano
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rbenv'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
# Optional
require 'capistrano/eye'
require 'capistrano/dotgpg'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
#config/deploy.rb
set :application, 'test'
set :user, 'test'
set :group, 'www-data'
set :rbenv_type, :user
set :rbenv_ruby, '2.2.2'
set :rbenv_map_bins, %w{rake gem bundle ruby rails eye}
set :repo_url, 'git@github.com:example/test.git'
set :deploy_to, "/home/#{fetch(:user)}/#{fetch(:application)}"
set :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
set :linked_dirs, %w(log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system)
set :keep_releases, 5
set :log_level, :info
#config/deploy/staging.rb
server 'test.example.com', user: 'test', roles: %w{web app}
#config/test.eye
Eye.config do
logger File.join(ENV["HOME"],'eye/eye.log'), 2, 20.megabytes
end
Eye.application 'test' do
working_dir File.expand_path(File.join(File.dirname(__FILE__), '..'))
if File.exist? File.join(working_dir, 'Gemfile')
clear_bundler_env
env 'BUNDLE_GEMFILE' => File.join(working_dir, 'Gemfile')
end
process :sidekiq do
start_command "bundle exec dotenv sidekiq"
pid_file "./tmp/pids/sidekiq.pid"
stdall "./log/sidekiq.log"
daemonize true
stop_signals [:QUIT, 15.seconds, :TERM, 5.seconds, :KILL]
check :cpu, :every => 30, :below => 100, :times => 5
check :memory, :every => 30, :below => 300.megabytes, :times => 5
end
process :unicorn do
start_command "bundle exec dotenv unicorn -Dc ./config/unicorn.rb"
pid_file "./tmp/pids/unicorn.pid"
stdall "./log/unicorn.log"
stop_signals [:TERM, 10.seconds]
#restart_command "kill -USR2 {PID}"
check :cpu, :every => 30, :below => 80, :times => 3
check :memory, :every => 30, :below => 150.megabytes, :times => [3,5]
start_timeout 100.seconds
restart_grace 30.seconds
monitor_children do
stop_command "kill -QUIT {PID}"
check :cpu, :every => 30, :below => 80, :times => 3
check :memory, :every => 30, :below => 150.megabytes, :times => [3,5]
end
end
end
gem 'dotgpg'
gem 'capistrano', '~> 3.2'
gem 'capistrano-rails'
gem 'capistrano-rbenv'
gem 'capistrano-eye'
gem 'capistrano-dotgpg'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment