diff --git a/Gemfile b/Gemfile index 1daa4d1..58e012c 100644 --- a/Gemfile +++ b/Gemfile @@ -36,12 +36,12 @@ gem 'newrelic_rpm' gem 'puma' -gem 'mina', require: false +gem 'mina', '~> 1.0.6', require: false +gem 'mina-puma', '~> 1.0.1', require: false +gem 'mina-multistage', '~> 1.0.3', require: false +gem 'mina-sidekiq', '~> 1.0.1', require: false +gem 'mina-logs', '~> 1.0.1', require: false -gem 'mina-multistage', require: false -gem 'mina-sidekiq', require: false -gem 'mina-puma', require: false -gem 'mina-logs', require: false gem 'browser_warrior' group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 1921bbd..775f2ee 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -372,11 +372,11 @@ DEPENDENCIES js_cookie_rails kaminari! listen (~> 3.x) - mina - mina-logs - mina-multistage - mina-puma - mina-sidekiq + mina (~> 1.0.6) + mina-logs (~> 1.0.1) + mina-multistage (~> 1.0.3) + mina-puma (~> 1.0.1) + mina-sidekiq (~> 1.0.1) mini_magick newrelic_rpm nokogiri diff --git a/config/deploy.rb b/config/deploy.rb index 267a4d2..c5d7c58 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -7,52 +7,79 @@ require 'mina/rails' require 'mina/git' require 'mina/rvm' require 'mina/puma' -require 'mina_sidekiq/tasks' +require "mina_sidekiq/tasks" require 'mina/logs' -# Manually create these paths in shared/ (eg: shared/config/database.yml) in your server. -# They will be linked in the 'deploy:link_shared_paths' step. -set :shared_paths, ['config/database.yml', 'config/application.yml', 'log', 'tmp', 'public/uploads', 'public/personal' ] +set :shared_dirs, fetch(:shared_dirs, []).push('log', 'public/uploads', 'public/personal') +set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'config/application.yml') + +set :sidekiq_pid, ->{ "#{fetch(:shared_path)}/tmp/pids/sidekiq.pid" } task :environment do - invoke :'rvm:use[2.3.1]' + invoke :'rvm:use', '2.3.1' end task :setup => :environment do - ['config', 'log', 'tmp', 'public/uploads', 'public/personal'].each do |dir| - queue! %[mkdir -p "#{deploy_to}/shared/#{dir}"] - queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/#{dir}"] - end + command %[mkdir -p "#{fetch(:shared_path)}/tmp/sockets"] + command %[chmod g+rx,u+rwx "#{fetch(:shared_path)}/tmp/sockets"] - ['config/database.yml', 'config/application.yml'].each do |file| - queue! %[touch "#{deploy_to}/shared/#{file}"] - queue %[echo "-----> Be sure to edit 'shared/#{file}'."] - end + command %[mkdir -p "#{fetch(:shared_path)}/tmp/pids"] + command %[chmod g+rx,u+rwx "#{fetch(:shared_path)}/tmp/pids"] - queue! %[mkdir -p "#{deploy_to}/shared/pids/"] - queue! %[mkdir -p "#{deploy_to}/shared/tmp/sockets"] - queue! %[mkdir -p "#{deploy_to}/shared/tmp/pids"] - queue! %[mkdir -p "#{deploy_to}/shared/log/"] + command %[mkdir -p "#{fetch(:shared_path)}/log"] + command %[chmod g+rx,u+rwx "#{fetch(:shared_path)}/log"] + + command %[mkdir -p "#{fetch(:shared_path)}/public/uploads"] + command %[chmod g+rx,u+rwx "#{fetch(:shared_path)}/public/uploads"] + + command %[mkdir -p "#{fetch(:shared_path)}/config"] + command %[chmod g+rx,u+rwx "#{fetch(:shared_path)}/config"] + + command %[touch "#{fetch(:shared_path)}/config/application.yml"] + command %[echo "-----> Be sure to edit '#{fetch(:shared_path)}/config/application.yml'"] + + command %[touch "#{fetch(:shared_path)}/config/database.yml"] + command %[echo "-----> Be sure to edit '#{fetch(:shared_path)}/config/database.yml'"] end desc "Deploys the current version to the server." task :deploy => :environment do + command %[echo "-----> Server: #{fetch(:domain)}"] + command %[echo "-----> Path: #{fetch(:deploy_to)}"] + command %[echo "-----> Branch: #{fetch(:branch)}"] + deploy do - # Put things that will set up an empty directory into a fully set-up - # instance of your project. + invoke :'sidekiq:quiet' invoke :'git:clone' invoke :'deploy:link_shared_paths' invoke :'bundle:install' invoke :'rails:db_migrate' invoke :'rails:assets_precompile' + invoke :'deploy:cleanup' - to :launch do - # Insure puma is start when restart it - invoke :'puma:start' - invoke :'puma:phased_restart' + on :launch do + invoke :'rvm:use', '2.3.1' + invoke :'puma:hard_restart' invoke :'sidekiq:restart' end - - invoke :'deploy:cleanup' + end +end + +desc "Deploys the current version to the server." +task :first_deploy => :environment do + command %[echo "-----> Server: #{fetch(:domain)}"] + command %[echo "-----> Path: #{fetch(:deploy_to)}"] + command %[echo "-----> Branch: #{fetch(:branch)}"] + + deploy do + invoke :'git:clone' + invoke :'deploy:link_shared_paths' + invoke :'bundle:install' + invoke :'deploy:cleanup' + + on :launch do + invoke :'rvm:use', '2.3.1' + invoke :'rails:db_create' + end end end