diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index ccbccc3d..00000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.2.0 diff --git a/Capfile b/Capfile index 07e8f85e..6b226745 100644 --- a/Capfile +++ b/Capfile @@ -20,6 +20,8 @@ require 'capistrano/rvm' require 'capistrano/bundler' require 'capistrano/rails/assets' # require 'capistrano/rails/migrations' +require 'capistrano/puma' +require "airbrussh/capistrano" # Loads custom tasks from `lib/capistrano/tasks' if you have any defined. Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } diff --git a/Gemfile b/Gemfile index 146c5686..7efb48d8 100644 --- a/Gemfile +++ b/Gemfile @@ -2,10 +2,10 @@ source 'https://rails-assets.org' source 'https://rubygems.org' gem 'rails', '4.2.0' -gem 'rack-cors', :require => 'rack/cors' +gem 'rack-cors', require: 'rack/cors' # Bundle edge Rails instead: -# gem 'rails', :git => 'git://github.com/rails/rails.git' +# gem 'rails', git: 'git://github.com/rails/rails.git' # gem 'sqlite3' @@ -30,10 +30,10 @@ group :assets do #gem 'compass-rails' gem 'js-routes' gem "font-awesome-rails" - gem 'capistrano-local-precompile', require: false + #gem 'capistrano-local-precompile', require: false # See https://github.com/sstephenson/execjs#readme for more supported runtimes - #gem 'therubyracer', :platforms => :ruby + #gem 'therubyracer', platforms: :ruby gem 'uglifier', '>= 1.0.3' #gem "emblem-source", github: "machty/emblem.js" @@ -43,7 +43,7 @@ group :assets do gem 'foundation-rails' #, github: 'bterkuile/foundation-rails' gem 'ace-rails-ap' - #gem 'mustache' #, :require => 'mustache/railtie' + #gem 'mustache' #, require: 'mustache/railtie' end #gem 'less-rails' @@ -79,7 +79,7 @@ gem 'sucker_punch' #gem 'geokit' gem 'iso_country_codes' -#gem "less-rails-bootstrap-devise", :git => 'git://github.com/bigbento/less-rails-bootstrap-devise.git' +#gem "less-rails-bootstrap-devise", git: 'git://github.com/bigbento/less-rails-bootstrap-devise.git' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' @@ -105,14 +105,16 @@ group :development do gem 'letter_opener' # gem 'thin' gem 'faye' - gem 'capistrano', '~> 3.0', require: false - gem 'capistrano-rvm', '~> 0.1', require: false - gem 'capistrano-rails', '~> 1.1', require: false + gem 'capistrano', require: false + gem 'capistrano-bundler', require: false + gem 'capistrano-rvm', require: false + gem 'capistrano-rails', require: false + gem 'capistrano3-puma', require: false + gem "airbrussh", require: false gem 'spring' gem 'spring-commands-rspec' gem 'web-console', '~> 2.0.0' gem 'foreman' - gem 'thin' end group :test do @@ -125,12 +127,13 @@ group :test do gem 'launchy' gem 'fuubar' gem 'webmock' - #gem 'rb-fsevent', :require => false #if RUBY_PLATFORM =~ /darwin/i + #gem 'rb-fsevent', require: false #if RUBY_PLATFORM =~ /darwin/i gem 'simplecov', require: false end # Use unicorn as the app server # gem 'unicorn' +gem 'puma' # Deploy with Capistrano # gem 'capistrano' diff --git a/Gemfile.lock b/Gemfile.lock index d57d770f..b8e2aff5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -90,6 +90,8 @@ GEM thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.3.7) + airbrussh (0.4.1) + sshkit (>= 1.6.1, != 1.7.0) arel (6.0.0) barber (0.6.0) ember-source @@ -113,14 +115,15 @@ GEM capistrano-bundler (1.1.4) capistrano (~> 3.1) sshkit (~> 1.2) - capistrano-local-precompile (0.0.2) - capistrano capistrano-rails (1.1.2) capistrano (~> 3.1) capistrano-bundler (~> 1.1) capistrano-rvm (0.1.2) capistrano (~> 3.0) sshkit (~> 1.2) + capistrano3-puma (1.0.0) + capistrano (~> 3.0) + puma (>= 2.6) capybara (2.4.4) mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -149,7 +152,7 @@ GEM execjs coffee-script-source (1.9.1) colored (1.2) - colorize (0.7.5) + colorize (0.7.7) cookiejar (0.3.2) couchrest (1.2.0) mime-types (~> 1.15) @@ -157,7 +160,6 @@ GEM rest-client (~> 1.6.1) crack (0.4.2) safe_yaml (~> 1.0.0) - daemons (1.1.9) debug_inspector (0.0.2) devise (3.4.1) bcrypt (~> 3.0) @@ -320,6 +322,8 @@ GEM slop (~> 3.4) pry-rails (0.3.3) pry (>= 0.9.10) + puma (2.11.3) + rack (>= 1.1, < 2.0) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) rack (1.6.0) @@ -435,10 +439,6 @@ GEM temple (0.7.5) test_squad (0.0.1) rails - thin (1.6.3) - daemons (~> 1.0, >= 1.0.9) - eventmachine (~> 1.0) - rack (~> 1.0) thor (0.19.1) thread_safe (0.3.5) tilt (1.4.1) @@ -479,12 +479,14 @@ DEPENDENCIES active_attr active_decorator active_model_serializers (= 0.9.0) + airbrussh bourbon cancancan - capistrano (~> 3.0) - capistrano-local-precompile - capistrano-rails (~> 1.1) - capistrano-rvm (~> 0.1) + capistrano + capistrano-bundler + capistrano-rails + capistrano-rvm + capistrano3-puma capybara-screenshot cmtool! coffee-rails @@ -518,6 +520,7 @@ DEPENDENCIES paperclip poltergeist pry-rails + puma quiet_assets rack-cors rails (= 4.2.0) @@ -535,7 +538,6 @@ DEPENDENCIES spring-commands-rspec sucker_punch test_squad - thin turnip uglifier (>= 1.0.3) web-console (~> 2.0.0) diff --git a/config/deploy.rb b/config/deploy.rb index 5a375d41..5e7e4115 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -32,12 +32,23 @@ set :deploy_to, '/var/www/mozo.bar' # set :linked_files, %w{config/database.yml} # Default value for linked_dirs is [] -set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} +set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/assets} # Default value for default_env is {} # set :default_env, { path: "/opt/ruby/bin:$PATH" } set :default_env, {'DEPLOY' => 'yes'} +set :puma_threads, [4, 16] +set :puma_workers, 2 +set :puma_bind, "unix://#{shared_path}/tmp/sockets/app.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 :puma_preload_app, true +set :puma_worker_timeout, nil +set :puma_init_active_record, false # Change to true if using ActiveRecord + # Default value for keep_releases is 5 # set :keep_releases, 5 @@ -49,12 +60,12 @@ namespace :deploy do # Your restart mechanism here, for example: within release_path do #execute :rake, 'cache:clear', as: 'www-data' - with rails_env: fetch(:rails_env) do - execute :rake, 'dedigest_assets', as: 'www-data' - end + #with rails_env: fetch(:rails_env) do + #execute :rake, 'dedigest_assets', as: 'www-data' + #end end - execute :chown, "-R www-data:www-data", release_path - execute :chown, "-R www-data:www-data", release_path.join('public/assets/') + #execute :chown, "-R www-data:www-data", release_path + #execute :chown, "-R www-data:www-data", release_path.join('public/assets/') #execute :kill, capture("lsof -i:9022 -t") # kill counters, will reboot itself execute :touch, release_path.join('tmp/restart.txt') end @@ -72,6 +83,43 @@ namespace :deploy do end + namespace :assets do + + Rake::Task['deploy:assets:precompile'].clear_actions + Rake::Task['deploy:assets:backup_manifest'].clear_actions + + desc 'Precompile assets locally and upload to servers' + task :precompile do + on roles(fetch(:assets_roles)) do + run_locally do + with rails_env: fetch(:rails_env) do + execute 'bin/rake assets:precompile' + execute 'bin/rake dedigest_assets' + end + end + + #within release_path do + #with rails_env: fetch(:rails_env) do + #upload!('./public/assets/', "#{shared_path}/public/", recursive: true) + #end + #end + rsync_host = host + run_locally { execute "rsync -av --delete ./public/assets/ #{fetch(:user)}@#{rsync_host}:#{shared_path}/public/assets/" } + execute :chown, "-R www-data:www-data", shared_path.join('public/assets/') + + run_locally { execute 'rm -rf public/assets' } + end + end + + end + #desc 'Set config/puma.rb-symlink for upstart' + #task :puma_config do + #on roles(:app) do + #execute "ln -sf #{shared_path}/puma.rb #{release_path}/config/puma.rb" + #end + #end + #after :finishing, :puma_config + after :publishing, :restart do #deploy.update_remote_cache end