Add Capistrano
This commit is contained in:
parent
b6b2eef325
commit
6b054a8be2
|
@ -0,0 +1,18 @@
|
||||||
|
# Load DSL and set up stages
|
||||||
|
require "capistrano/setup"
|
||||||
|
|
||||||
|
# Include default deployment tasks
|
||||||
|
require "capistrano/deploy"
|
||||||
|
|
||||||
|
# Load the SCM plugin
|
||||||
|
require "capistrano/scm/git"
|
||||||
|
install_plugin Capistrano::SCM::Git
|
||||||
|
|
||||||
|
# Include tasks from other gems included in your Gemfile
|
||||||
|
require "rvm1/capistrano3"
|
||||||
|
require "capistrano/bundler"
|
||||||
|
require "capistrano/rails/assets"
|
||||||
|
require "capistrano/rails/migrations"
|
||||||
|
|
||||||
|
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
|
||||||
|
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
|
7
Gemfile
7
Gemfile
|
@ -81,6 +81,13 @@ group :development do
|
||||||
gem 'web-console', '< 3.0.0'
|
gem 'web-console', '< 3.0.0'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Deployment
|
||||||
|
group :development do
|
||||||
|
gem 'capistrano', '~> 3.7', require: false
|
||||||
|
gem 'capistrano-rails', require: false
|
||||||
|
gem 'rvm1-capistrano3', require: false
|
||||||
|
end
|
||||||
|
|
||||||
group :production do
|
group :production do
|
||||||
gem 'unicorn', group: :production
|
gem 'unicorn', group: :production
|
||||||
end
|
end
|
||||||
|
|
25
Gemfile.lock
25
Gemfile.lock
|
@ -45,6 +45,8 @@ GEM
|
||||||
thread_safe (~> 0.3, >= 0.3.4)
|
thread_safe (~> 0.3, >= 0.3.4)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
addressable (2.4.0)
|
addressable (2.4.0)
|
||||||
|
airbrussh (1.1.2)
|
||||||
|
sshkit (>= 1.6.1, != 1.7.0)
|
||||||
arel (6.0.3)
|
arel (6.0.3)
|
||||||
bcrypt (3.1.10)
|
bcrypt (3.1.10)
|
||||||
better_errors (2.1.1)
|
better_errors (2.1.1)
|
||||||
|
@ -75,6 +77,17 @@ GEM
|
||||||
buftok (0.2.0)
|
buftok (0.2.0)
|
||||||
builder (3.2.2)
|
builder (3.2.2)
|
||||||
byebug (8.2.2)
|
byebug (8.2.2)
|
||||||
|
capistrano (3.8.0)
|
||||||
|
airbrussh (>= 1.0.0)
|
||||||
|
i18n
|
||||||
|
rake (>= 10.0.0)
|
||||||
|
sshkit (>= 1.9.0)
|
||||||
|
capistrano-bundler (1.2.0)
|
||||||
|
capistrano (~> 3.1)
|
||||||
|
sshkit (~> 1.2)
|
||||||
|
capistrano-rails (1.2.3)
|
||||||
|
capistrano (~> 3.1)
|
||||||
|
capistrano-bundler (~> 1.1)
|
||||||
capybara (2.6.2)
|
capybara (2.6.2)
|
||||||
addressable
|
addressable
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
|
@ -339,6 +352,9 @@ GEM
|
||||||
naught (1.1.0)
|
naught (1.1.0)
|
||||||
nenv (0.2.0)
|
nenv (0.2.0)
|
||||||
nested_form (0.3.2)
|
nested_form (0.3.2)
|
||||||
|
net-scp (1.2.1)
|
||||||
|
net-ssh (>= 2.6.5)
|
||||||
|
net-ssh (4.1.0)
|
||||||
nokogiri (1.6.7.2)
|
nokogiri (1.6.7.2)
|
||||||
mini_portile2 (~> 2.0.0.rc2)
|
mini_portile2 (~> 2.0.0.rc2)
|
||||||
nokogumbo (1.4.7)
|
nokogumbo (1.4.7)
|
||||||
|
@ -471,6 +487,9 @@ GEM
|
||||||
sexp_processor (~> 4.0)
|
sexp_processor (~> 4.0)
|
||||||
ruby_parser (3.7.3)
|
ruby_parser (3.7.3)
|
||||||
sexp_processor (~> 4.1)
|
sexp_processor (~> 4.1)
|
||||||
|
rvm1-capistrano3 (1.4.0)
|
||||||
|
capistrano (~> 3.0)
|
||||||
|
sshkit (>= 1.2)
|
||||||
safe_yaml (1.0.4)
|
safe_yaml (1.0.4)
|
||||||
sanitize (4.0.1)
|
sanitize (4.0.1)
|
||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
|
@ -520,6 +539,9 @@ GEM
|
||||||
actionpack (>= 3.0)
|
actionpack (>= 3.0)
|
||||||
activesupport (>= 3.0)
|
activesupport (>= 3.0)
|
||||||
sprockets (>= 2.8, < 4.0)
|
sprockets (>= 2.8, < 4.0)
|
||||||
|
sshkit (1.13.0)
|
||||||
|
net-scp (>= 1.1.2)
|
||||||
|
net-ssh (>= 2.8.0)
|
||||||
sweetalert-rails (0.5.0)
|
sweetalert-rails (0.5.0)
|
||||||
railties (>= 3.1.0)
|
railties (>= 3.1.0)
|
||||||
temple (0.7.6)
|
temple (0.7.6)
|
||||||
|
@ -597,6 +619,8 @@ DEPENDENCIES
|
||||||
bootswatch-rails
|
bootswatch-rails
|
||||||
brakeman
|
brakeman
|
||||||
byebug
|
byebug
|
||||||
|
capistrano (~> 3.7)
|
||||||
|
capistrano-rails
|
||||||
capybara
|
capybara
|
||||||
coffee-rails (~> 4.1.0)
|
coffee-rails (~> 4.1.0)
|
||||||
database_cleaner
|
database_cleaner
|
||||||
|
@ -641,6 +665,7 @@ DEPENDENCIES
|
||||||
rollbar
|
rollbar
|
||||||
rspec-rails (~> 3.0.0)
|
rspec-rails (~> 3.0.0)
|
||||||
ruby-progressbar
|
ruby-progressbar
|
||||||
|
rvm1-capistrano3
|
||||||
sanitize
|
sanitize
|
||||||
sass-rails (~> 4.0.3)
|
sass-rails (~> 4.0.3)
|
||||||
sdoc (~> 0.4.1)
|
sdoc (~> 0.4.1)
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
# config valid only for current version of Capistrano
|
||||||
|
lock "3.7.1"
|
||||||
|
|
||||||
|
set :application, "retrospring"
|
||||||
|
set :repo_url, "git@git.rrerr.net:nilsding/retrospring.git"
|
||||||
|
|
||||||
|
# Default branch is :master
|
||||||
|
ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
|
||||||
|
|
||||||
|
# Default deploy_to directory is /var/www/my_app_name
|
||||||
|
set :deploy_to, "/usr/home/justask/apps/retrospring"
|
||||||
|
|
||||||
|
# Default value for :format is :airbrussh.
|
||||||
|
# set :format, :airbrussh
|
||||||
|
|
||||||
|
# You can configure the Airbrussh format using :format_options.
|
||||||
|
# These are the defaults.
|
||||||
|
# set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto
|
||||||
|
|
||||||
|
# Default value for :pty is false
|
||||||
|
# set :pty, true
|
||||||
|
|
||||||
|
# Default value for :linked_files is []
|
||||||
|
append :linked_files, "config/database.yml", "config/justask.yml", "config/secrets.yml"
|
||||||
|
|
||||||
|
# Default value for linked_dirs is []
|
||||||
|
append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/uploads", "public/system"
|
||||||
|
|
||||||
|
# Default value for default_env is {}
|
||||||
|
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
|
||||||
|
|
||||||
|
# Default value for keep_releases is 5
|
||||||
|
# set :keep_releases, 5
|
||||||
|
|
||||||
|
# Ruby version / RVM
|
||||||
|
set :rvm1_ruby_version, '2.3.3@retrospring'
|
||||||
|
|
||||||
|
# Restart the app server after successful deploy
|
||||||
|
after 'deploy:cleanup', 'deploy:restart'
|
|
@ -0,0 +1,39 @@
|
||||||
|
# Defines a single server with a list of roles and multiple properties.
|
||||||
|
server "dragon.nilsding.org", user: "justask", roles: %w{app db web}
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
# =============
|
||||||
|
# You can set any configuration variable like in config/deploy.rb
|
||||||
|
# These variables are then only loaded and set in this stage.
|
||||||
|
# For available Capistrano configuration variables see the documentation page.
|
||||||
|
# http://capistranorb.com/documentation/getting-started/configuration/
|
||||||
|
# Feel free to add new variables to customise your setup.
|
||||||
|
|
||||||
|
set :rails_env, :production
|
||||||
|
|
||||||
|
# Custom SSH Options
|
||||||
|
# ==================
|
||||||
|
# You may pass any option but keep in mind that net/ssh understands a
|
||||||
|
# limited set of options, consult the Net::SSH documentation.
|
||||||
|
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
|
||||||
|
#
|
||||||
|
# Global options
|
||||||
|
# --------------
|
||||||
|
# set :ssh_options, {
|
||||||
|
# keys: %w(/home/rlisowski/.ssh/id_rsa),
|
||||||
|
# forward_agent: false,
|
||||||
|
# auth_methods: %w(password)
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# The server-based syntax can be used to override options:
|
||||||
|
# ------------------------------------
|
||||||
|
# server "example.com",
|
||||||
|
# user: "user_name",
|
||||||
|
# roles: %w{web app},
|
||||||
|
# ssh_options: {
|
||||||
|
# user: "user_name", # overrides user setting above
|
||||||
|
# keys: %w(/home/user_name/.ssh/id_rsa),
|
||||||
|
# forward_agent: false,
|
||||||
|
# auth_methods: %w(publickey password)
|
||||||
|
# # password: "please use keys"
|
||||||
|
# }
|
|
@ -0,0 +1,32 @@
|
||||||
|
namespace :deploy do
|
||||||
|
task :start do
|
||||||
|
on roles(:all) do
|
||||||
|
rvm_prefix = "#{fetch(:rvm1_auto_script_path)}/rvm-auto.sh #{fetch(:rvm1_ruby_version)}"
|
||||||
|
execute :tmux, 'new-session',
|
||||||
|
'-d',
|
||||||
|
'-s', 'retrospring',
|
||||||
|
'-n', 'retrospring',
|
||||||
|
'-c', '/usr/home/justask/apps/retrospring/current',
|
||||||
|
"'#{rvm_prefix} bundle exec foreman start'"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
task :stop do
|
||||||
|
on roles(:all) do
|
||||||
|
execute :sh, '-c', '\'tmux list-panes -t justask -F "#{pane_pid}" | xargs kill\''
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
desc 'Restart the server'
|
||||||
|
task :restart do
|
||||||
|
on roles(:all) do
|
||||||
|
info 'Restarting application server'
|
||||||
|
invoke('deploy:stop')
|
||||||
|
|
||||||
|
info 'Waiting 2 seconds'
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
invoke('deploy:start')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue