Commit 2aef6dc1 by zmj

添加部署想过信息

parent 000436c5
# Load DSL and set up stages
require "capistrano/setup"
# Include default deployment tasks
require "capistrano/deploy"
require 'capistrano/rvm'
require 'capistrano/puma'
require 'capistrano/rails'
require 'capistrano/bundler'
require 'capistrano/sidekiq'
require "capistrano/scm/git"
install_plugin Capistrano::Puma
install_plugin Capistrano::SCM::Git
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
...@@ -49,6 +49,13 @@ group :development do ...@@ -49,6 +49,13 @@ group :development do
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring' gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0' gem 'spring-watcher-listen', '~> 2.0.0'
# deplopy
gem "capistrano", "~> 3.11", require: false
gem 'capistrano-rvm', '~> 0.1.2', require: false
gem 'capistrano-rails', '~> 1.4', require: false
gem 'capistrano3-puma', '~> 3.1', '>= 3.1.1', require: false # https://github.com/seuros/capistrano-puma
gem 'capistrano-sidekiq', '~> 1.0', '>= 1.0.2', require: false
end end
group :test do group :test do
......
...@@ -44,6 +44,8 @@ GEM ...@@ -44,6 +44,8 @@ GEM
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.6.0) addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0) public_suffix (>= 2.0.2, < 4.0)
airbrussh (1.3.1)
sshkit (>= 1.6.1, != 1.7.0)
archive-zip (0.12.0) archive-zip (0.12.0)
io-like (~> 0.3.0) io-like (~> 0.3.0)
arel (9.0.0) arel (9.0.0)
...@@ -52,6 +54,26 @@ GEM ...@@ -52,6 +54,26 @@ GEM
msgpack (~> 1.0) msgpack (~> 1.0)
builder (3.2.3) builder (3.2.3)
byebug (11.0.1) byebug (11.0.1)
capistrano (3.11.0)
airbrussh (>= 1.0.0)
i18n
rake (>= 10.0.0)
sshkit (>= 1.9.0)
capistrano-bundler (1.5.0)
capistrano (~> 3.1)
capistrano-rails (1.4.0)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capistrano-rvm (0.1.2)
capistrano (~> 3.0)
sshkit (~> 1.2)
capistrano-sidekiq (1.0.2)
capistrano (>= 3.9.0)
sidekiq (>= 3.4)
capistrano3-puma (3.1.1)
capistrano (~> 3.7)
capistrano-bundler
puma (~> 3.4)
capybara (3.20.2) capybara (3.20.2)
addressable addressable
mini_mime (>= 0.1.3) mini_mime (>= 0.1.3)
...@@ -110,6 +132,9 @@ GEM ...@@ -110,6 +132,9 @@ GEM
minitest (5.11.3) minitest (5.11.3)
msgpack (1.2.10) msgpack (1.2.10)
multi_xml (0.6.0) multi_xml (0.6.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (5.1.0)
nio4r (2.3.1) nio4r (2.3.1)
nokogiri (1.10.3) nokogiri (1.10.3)
mini_portile2 (~> 2.4.0) mini_portile2 (~> 2.4.0)
...@@ -203,6 +228,9 @@ GEM ...@@ -203,6 +228,9 @@ GEM
activesupport (>= 4.0) activesupport (>= 4.0)
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
sqlite3 (1.4.1) sqlite3 (1.4.1)
sshkit (1.18.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
thor (0.20.3) thor (0.20.3)
thread_safe (0.3.6) thread_safe (0.3.6)
tilt (2.0.9) tilt (2.0.9)
...@@ -230,6 +258,11 @@ PLATFORMS ...@@ -230,6 +258,11 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
bootsnap (>= 1.1.0) bootsnap (>= 1.1.0)
byebug byebug
capistrano (~> 3.11)
capistrano-rails (~> 1.4)
capistrano-rvm (~> 0.1.2)
capistrano-sidekiq (~> 1.0, >= 1.0.2)
capistrano3-puma (~> 3.1, >= 3.1.1)
capybara (>= 2.15) capybara (>= 2.15)
chromedriver-helper chromedriver-helper
coffee-rails (~> 4.2) coffee-rails (~> 4.2)
......
# config valid for current version and patch releases of Capistrano
lock '~> 3.11.0'
set :rvm_type, :auto # Defaults to: :auto
set :rvm_ruby_version, '2.6.0'
set :god_sidekiq_group, 'app_push_sidekiq'
set :puma_role, 'app'
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
set :linked_files, %w[
config/credentials.yml.enc
config/puma.rb
config/master.key
config/sidekiq.yml
config/push.yml
config/settings.yml
config/app.yml
]
set :linked_dirs, %w[
log tmp/pids
tmp/cache
tmp/sockets
vendor/bundle
]
namespace :sidekiq do
desc 'restart sidekiq by god'
# dev/testing/staging 不用god 监控
task :god_restart do
on roles(:sidekiq_god), in: :parallel do
execute [
'source ~/.rvm/scripts/rvm',
'god',
"god stop #{fetch(:god_sidekiq_group)}",
'sleep 30',
"god remove #{fetch(:god_sidekiq_group)}",
"god load #{release_path}/config/sidekiq.god"
].join('; ')
end
end
end
namespace :puma do
desc 'Create Directories for Puma Pids and Socket'
task :make_dirs do
on roles(:app) do
execute "mkdir #{fetch(:shared_path)}/tmp/sockets -p"
execute "mkdir #{fetch(:shared_path)}/tmp/pids -p"
end
end
before :start, :make_dirs
end
namespace :deploy do
desc "Make sure local git is in sync with remote."
task :check_revision do
on roles(:app) do
unless `git rev-parse HEAD` == `git rev-parse origin/#{fetch(:branch)}`
puts "WARNING: HEAD is not the same as origin/#{fetch(:branch)}"
puts "Run `git push` to sync changes."
exit
end
end
end
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
invoke 'sidekiq:god_restart'
end
end
before :starting, :check_revision
after :finishing, :compile_assets
after :finishing, :restart
after :publishing, :restart
end
require 'json'
file = File.read("config/server.json")
deploy_config = JSON.parse(file)
branch = deploy_config['branch'] || 'dev'
set :branch, branch
append :linked_files, 'config/server.json'
set :stage, :production
set :rails_env, :production
set :port, 40022
set :repo_url, 'ssh://gitlab@gitlab.ikcrm.com:40022/ikcrm_server/app_push.git'
set :application, 'app_push'
set :deploy_to, deploy_config['deploy_to']
set :shared_path, -> { fetch(:deploy_to) + '/shared' }
# Don't change these unless you know what you're doing
set :pty, true
set :use_sudo, false
set :stage, :production
set :deploy_via, :remote_cache
set :puma_bind, "unix://#{fetch(:shared_path)}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state, "#{fetch(:shared_path)}/tmp/pids/puma.state"
set :puma_pid, "#{fetch(:shared_path)}/tmp/pids/puma.pid"
set :puma_access_log, "#{fetch(:release_path)}/log/puma_error.log"
set :puma_error_log, "#{fetch(:release_path)}/log/puma_access.log"
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true # Change to true if using ActiveRecord
deploy_config['servers'].each do |set|
server set['server'], user: set['user'], roles: set['roles'], my_property: :my_value
end
require 'json'
file = File.read("config/server.json")
deploy_config = JSON.parse(file)
branch = deploy_config['branch'] || 'release'
set :branch, branch
append :linked_files, 'config/server.json'
set :stage, :production
set :rails_env, :production
set :port, 40022
set :repo_url, 'ssh://gitlab@gitlab.ikcrm.com:40022/ikcrm_server/app_push.git'
set :application, 'app_push'
set :deploy_to, deploy_config['deploy_to']
set :shared_path, -> { fetch(:deploy_to) + '/shared' }
# Don't change these unless you know what you're doing
set :pty, true
set :use_sudo, false
set :stage, :production
set :deploy_via, :remote_cache
set :puma_bind, "unix://#{fetch(:shared_path)}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state, "#{fetch(:shared_path)}/tmp/pids/puma.state"
set :puma_pid, "#{fetch(:shared_path)}/tmp/pids/puma.pid"
set :puma_access_log, "#{fetch(:release_path)}/log/puma_error.log"
set :puma_error_log, "#{fetch(:release_path)}/log/puma_access.log"
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true # Change to true if using ActiveRecord
deploy_config['servers'].each do |set|
server set['server'], user: set['user'], roles: set['roles'], my_property: :my_value
end
require 'json'
file = File.read("config/server.json")
deploy_config = JSON.parse(file)
branch = deploy_config['branch'] || 'master'
set :branch, branch
append :linked_files, 'config/server.json'
set :stage, :production
set :rails_env, :production
set :port, 40022
set :repo_url, 'ssh://gitlab@gitlab.ikcrm.com:40022/ikcrm_server/app_push.git'
set :application, 'app_push'
set :deploy_to, deploy_config['deploy_to']
set :shared_path, -> { fetch(:deploy_to) + '/shared' }
# Don't change these unless you know what you're doing
set :pty, true
set :use_sudo, false
set :stage, :production
set :deploy_via, :remote_cache
set :puma_bind, "unix://#{fetch(:shared_path)}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state, "#{fetch(:shared_path)}/tmp/pids/puma.state"
set :puma_pid, "#{fetch(:shared_path)}/tmp/pids/puma.pid"
set :puma_access_log, "#{fetch(:release_path)}/log/puma_error.log"
set :puma_error_log, "#{fetch(:release_path)}/log/puma_access.log"
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true # Change to true if using ActiveRecord
deploy_config['servers'].each do |set|
server set['server'], user: set['user'], roles: set['roles'], my_property: :my_value
end
require 'json'
file = File.read("config/server.json")
deploy_config = JSON.parse(file)
branch = deploy_config['branch'] || 'testing'
set :branch, branch
append :linked_files, 'config/server.json'
set :stage, :production
set :rails_env, :production
set :port, 40022
set :repo_url, 'ssh://gitlab@gitlab.ikcrm.com:40022/ikcrm_server/app_push.git'
set :application, 'app_push'
set :deploy_to, deploy_config['deploy_to']
set :shared_path, -> { fetch(:deploy_to) + '/shared' }
# Don't change these unless you know what you're doing
set :pty, true
set :use_sudo, false
set :stage, :production
set :deploy_via, :remote_cache
set :puma_bind, "unix://#{fetch(:shared_path)}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state, "#{fetch(:shared_path)}/tmp/pids/puma.state"
set :puma_pid, "#{fetch(:shared_path)}/tmp/pids/puma.pid"
set :puma_access_log, "#{fetch(:release_path)}/log/puma_error.log"
set :puma_error_log, "#{fetch(:release_path)}/log/puma_access.log"
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true # Change to true if using ActiveRecord
deploy_config['servers'].each do |set|
server set['server'], user: set['user'], roles: set['roles'], my_property: :my_value
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment