From 58d46e2b3565d58a4d049dd821836f01e95f0f89 Mon Sep 17 00:00:00 2001 From: Corey Date: Thu, 27 Oct 2016 16:33:55 -0700 Subject: [PATCH] Reset Capistrano files --- Capfile | 14 +-- config/deploy.rb | 97 +++++-------------- .../deploy/{productions.rb => production.rb} | 3 +- config/deploy/staging.rb | 61 ++++++++++++ 4 files changed, 93 insertions(+), 82 deletions(-) rename config/deploy/{productions.rb => production.rb} (94%) create mode 100644 config/deploy/staging.rb diff --git a/Capfile b/Capfile index 3e30693..4667537 100644 --- a/Capfile +++ b/Capfile @@ -14,12 +14,14 @@ require "capistrano/deploy" # https://github.com/capistrano/bundler # https://github.com/capistrano/rails # https://github.com/capistrano/passenger - -require 'capistrano/bundler' -require 'capistrano/rvm' -require 'capistrano/rails/assets' -require 'capistrano/rails/migrations' -require 'capistrano/puma' +# +# require 'capistrano/rvm' +# require 'capistrano/rbenv' +# require 'capistrano/chruby' +# require 'capistrano/bundler' +# require 'capistrano/rails/assets' +# require 'capistrano/rails/migrations' +# require 'capistrano/passenger' # Load custom tasks from `lib/capistrano/tasks` if you have any defined Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r } diff --git a/config/deploy.rb b/config/deploy.rb index f368080..1f12a1e 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,87 +1,36 @@ # config valid only for current version of Capistrano lock '3.6.1' -server '172.31.25.139', port: 80, roles: [:web, :app, :db], primary: true +set :application, 'my_app_name' +set :repo_url, 'git@example.com:me/my_repo.git' -set :application, 'sportsello' -set :repo_url, 'git@example.com:c-brooks/sportsello.git' +# Default branch is :master +# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp -set :user, 'deploy' -set :puma_threads, [4, 16] -set :puma_workers, 0 +# Default deploy_to directory is /var/www/my_app_name +# set :deploy_to, '/var/www/my_app_name' -# 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 :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}" -set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock" -set :puma_state, "#{shared_path}/tmp/pids/puma.state" -set :puma_pid, "#{shared_path}/tmp/pids/puma.pid" -set :puma_access_log, "#{release_path}/log/puma.error.log" -set :puma_error_log, "#{release_path}/log/puma.access.log" -set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) } -set :puma_preload_app, true -set :puma_worker_timeout, nil -set :puma_init_active_record, true # Change to false when not using ActiveRecord +# Default value for :scm is :git +# set :scm, :git -## Defaults: -# set :scm, :git -# set :branch, :master -# set :format, :pretty -# set :log_level, :debug -# set :keep_releases, 5 - -## Linked Files & Directories (Default None): -# set :linked_files, %w{config/database.yml} -# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} +# Default value for :format is :airbrussh. +# set :format, :airbrussh -namespace :puma do - desc 'Create Directories for Puma Pids and Socket' - task :make_dirs do - on roles(:app) do - execute "mkdir #{shared_path}/tmp/sockets -p" - execute "mkdir #{shared_path}/tmp/pids -p" - end - end +# 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 - before :start, :make_dirs -end +# Default value for :pty is false +# set :pty, true -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/master` - puts "WARNING: HEAD is not the same as origin/master" - puts "Run `git push` to sync changes." - exit - end - end - end +# Default value for :linked_files is [] +# append :linked_files, 'config/database.yml', 'config/secrets.yml' - desc 'Initial Deploy' - task :initial do - on roles(:app) do - before 'deploy:restart', 'puma:start' - invoke 'deploy' - end - end +# Default value for linked_dirs is [] +# append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system' - desc 'Restart application' - task :restart do - on roles(:app), in: :sequence, wait: 5 do - invoke 'puma:restart' - end - end +# Default value for default_env is {} +# set :default_env, { path: "/opt/ruby/bin:$PATH" } - before :starting, :check_revision - after :finishing, :compile_assets - after :finishing, :cleanup - after :finishing, :restart -end - -# ps aux | grep puma # Get puma pid -# kill -s SIGUSR2 pid # Restart puma -# kill -s SIGTERM pid # Stop puma +# Default value for keep_releases is 5 +# set :keep_releases, 5 diff --git a/config/deploy/productions.rb b/config/deploy/production.rb similarity index 94% rename from config/deploy/productions.rb rename to config/deploy/production.rb index 738c82b..4fc06fa 100644 --- a/config/deploy/productions.rb +++ b/config/deploy/production.rb @@ -7,8 +7,7 @@ # server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value # server 'db.example.com', user: 'deploy', roles: %w{db} -server '172.31.25.139', user: 'deploy', roles: %w{web app db} -# server '52.2.139.74', user: 'deploy', roles: %w{web app db} + # role-based syntax # ================== diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb new file mode 100644 index 0000000..4fc06fa --- /dev/null +++ b/config/deploy/staging.rb @@ -0,0 +1,61 @@ +# server-based syntax +# ====================== +# Defines a single server with a list of roles and multiple properties. +# You can define all roles on a single server, or split them: + +# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value +# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value +# server 'db.example.com', user: 'deploy', roles: %w{db} + + + +# role-based syntax +# ================== + +# Defines a role with one or multiple servers. The primary server in each +# group is considered to be the first unless any hosts have the primary +# property set. Specify the username and a domain or IP for the server. +# Don't use `:all`, it's a meta role. + +# role :app, %w{deploy@example.com}, my_property: :my_value +# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value +# role :db, %w{deploy@example.com} + + + +# 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. + + + +# 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' +# }