diff --git a/src/ruby/meetings/.ruby-version b/src/ruby/meetings/.ruby-version index c1026d2..262714f 100644 --- a/src/ruby/meetings/.ruby-version +++ b/src/ruby/meetings/.ruby-version @@ -1 +1 @@ -ruby-2.3.1 +ruby-2.4.0 diff --git a/src/ruby/meetings/Capfile b/src/ruby/meetings/Capfile index d51ef1f..deeafa9 100644 --- a/src/ruby/meetings/Capfile +++ b/src/ruby/meetings/Capfile @@ -20,6 +20,6 @@ require 'rvm1/capistrano3' require 'capistrano/bundler' require 'capistrano/rails' require 'capistrano/rails/migrations' - +require 'capistrano/passenger' # 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/src/ruby/meetings/Gemfile b/src/ruby/meetings/Gemfile index 107c5a6..13521c1 100644 --- a/src/ruby/meetings/Gemfile +++ b/src/ruby/meetings/Gemfile @@ -1,17 +1,10 @@ # Avoid warnings about the git protocol being insecure when using github repos. # https://github.com/bundler/bundler/issues/4978 -git_source(:github) do |repo_name| - repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") - "https://github.com/#{repo_name}.git" -end - -source 'https://rubygems.org' #https://github.com/twbs/bootstrap-rubygem +source 'https://rubygems.org' source 'https://rails-assets.org' do gem 'rails-assets-tether', '>= 1.1.0' end - - # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.0.0', '>= 5.0.0.1' # Use postgresql as the database for Active Record @@ -41,42 +34,43 @@ gem 'jbuilder', '~> 2.5' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development -gem 'unicorn' - -group :development, :test do - # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug', platform: :mri -end - -group :development do - # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. - gem 'web-console' - gem 'listen', '~> 3.0.5' - # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring' - gem 'spring-watcher-listen', '~> 2.0.0' -end - -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] +gem "passenger", ">= 5.0.25", require: "phusion_passenger/rack_handler" +gem 'draper', "3.0.0.pre1" gem 'bootstrap', '~> 4.0.0.alpha4' -gem 'carrierwave' -gem 'mini_magick' -gem 'draper', github: 'drapergem/draper' gem 'haml-rails' gem 'country_select' gem 'kaminari' gem "htmlentities" -gem 'factory_girl_rails' gem 'active_model_serializers', '~> 0.10.0' gem 'activemodel-serializers-xml' gem 'swagger-blocks' gem 'jsonapi-resources' -gem 'globalize', github: 'JohnSmall/globalize' gem 'rack-cors', :require => 'rack/cors' +group :development do + # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. + gem 'web-console' + gem 'listen', '~> 3.0.5' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + gem 'capistrano', '~> 3.6' + gem 'capistrano-rails', '~> 1.1' + gem 'capistrano-bundler', '~> 1.1.2' + gem 'capistrano-passenger' + gem 'railroady' + gem 'rvm1-capistrano3', require: false + gem 'git' + gem 'spring-commands-rspec' + gem 'spring-commands-cucumber' + #gem 'capistrano-git-submodule-strategy', '~> 0.1', :github => 'ekho/capistrano-git-submodule-strategy' +end + group :development, :test do + gem 'byebug', platform: :mri gem 'mailcatcher' gem 'syntax' gem 'rspec-rails' @@ -84,9 +78,9 @@ group :development, :test do gem 'cucumber-rails', require: false gem 'awesome_print' gem 'webmock' - gem 'capistrano-git-submodule-strategy', '~> 0.1', github: 'ekho/capistrano-git-submodule-strategy' gem 'faraday' gem 'jsonpath' + gem 'factory_girl_rails' end group :test do @@ -102,14 +96,3 @@ group :test do gem 'rails-controller-testing' end -group :development do - gem 'capistrano', '~> 3.6' - gem 'capistrano-rails', '~> 1.1' - gem 'capistrano-bundler', '~> 1.1.2' - gem 'capistrano-passenger' - gem 'railroady' - gem 'rvm1-capistrano3', require: false - gem 'git' - gem 'spring-commands-rspec' - gem 'spring-commands-cucumber' -end diff --git a/src/ruby/meetings/Gemfile.lock b/src/ruby/meetings/Gemfile.lock index ae862b3..ae76344 100644 --- a/src/ruby/meetings/Gemfile.lock +++ b/src/ruby/meetings/Gemfile.lock @@ -1,30 +1,3 @@ -GIT - remote: https://github.com/JohnSmall/globalize.git - revision: 7d507472e4076c720d798736137eb28d169eb1a1 - specs: - globalize (5.1.0) - activemodel (>= 4.2, < 5.1) - activerecord (>= 4.2, < 5.1) - request_store (~> 1.0) - -GIT - remote: https://github.com/drapergem/draper.git - revision: ab51bf06d111c6278bd3bc0ca781655ae61cc4b9 - specs: - draper (3.0.0.pre1) - actionpack (~> 5.0) - activemodel (~> 5.0) - activemodel-serializers-xml (~> 1.0) - activesupport (~> 5.0) - request_store (~> 1.0) - -GIT - remote: https://github.com/ekho/capistrano-git-submodule-strategy.git - revision: 559f6b08992027b2380a54b1b4b4cf55a3f10680 - specs: - capistrano-git-submodule-strategy (0.1.23) - capistrano (>= 3.1.0, < 3.7) - GEM remote: https://rubygems.org/ remote: https://rails-assets.org/ @@ -111,10 +84,6 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) - carrierwave (1.0.0) - activemodel (>= 4.0.0) - activesupport (>= 4.0.0) - mime-types (>= 1.16) case_transform (0.2) activesupport childprocess (0.5.9) @@ -159,6 +128,12 @@ GEM database_cleaner (1.5.3) debug_inspector (0.0.2) diff-lcs (1.3) + draper (3.0.0.pre1) + actionpack (~> 5.0) + activemodel (~> 5.0) + activemodel-serializers-xml (~> 1.0) + activesupport (~> 5.0) + request_store (~> 1.0) email_spec (2.1.0) htmlentities (~> 4.3.3) launchy (~> 2.1) @@ -225,7 +200,6 @@ GEM activerecord kaminari-core (= 1.0.1) kaminari-core (1.0.1) - kgio (2.11.0) launchy (2.4.3) addressable (~> 2.3) listen (3.0.8) @@ -249,7 +223,6 @@ GEM mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) - mini_magick (4.6.0) mini_portile2 (2.1.0) minitest (5.10.1) money (6.8.1) @@ -264,6 +237,9 @@ GEM nio4r (1.2.1) nokogiri (1.6.8.1) mini_portile2 (~> 2.1.0) + passenger (5.1.2) + rack + rake (>= 0.8.1) pg (0.19.0) poltergeist (1.12.0) capybara (~> 2.1) @@ -304,7 +280,6 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - raindrops (0.17.0) rake (12.0.0) rb-fsevent (0.9.8) rb-inotify (0.9.7) @@ -406,9 +381,6 @@ GEM uglifier (3.0.4) execjs (>= 0.3.0, < 3) unicode_utils (1.4.0) - unicorn (5.2.0) - kgio (~> 2.6) - raindrops (~> 0.7) web-console (3.4.0) actionview (>= 5.0) activemodel (>= 5.0) @@ -436,21 +408,18 @@ DEPENDENCIES byebug capistrano (~> 3.6) capistrano-bundler (~> 1.1.2) - capistrano-git-submodule-strategy (~> 0.1)! capistrano-passenger capistrano-rails (~> 1.1) capybara - carrierwave coffee-rails (~> 4.2) country_select cucumber-rails database_cleaner - draper! + draper (= 3.0.0.pre1) email_spec factory_girl_rails faraday git - globalize! haml-rails htmlentities jbuilder (~> 2.5) @@ -461,7 +430,7 @@ DEPENDENCIES launchy listen (~> 3.0.5) mailcatcher - mini_magick + passenger (>= 5.0.25) pg (~> 0.18) poltergeist puma (~> 3.0) @@ -485,11 +454,9 @@ DEPENDENCIES swagger-blocks syntax turbolinks (~> 5) - tzinfo-data uglifier (>= 1.3.0) - unicorn web-console webmock BUNDLED WITH - 1.14.0 + 1.14.3 diff --git a/src/ruby/meetings/config/deploy.rb b/src/ruby/meetings/config/deploy.rb index 13db49e..ff0f8ae 100644 --- a/src/ruby/meetings/config/deploy.rb +++ b/src/ruby/meetings/config/deploy.rb @@ -1,4 +1,8 @@ # config valid only for Capistrano 3.1 +# See http://stackoverflow.com/questions/29168/deploying-a-git-subdirectory-in-capistrano/6969505#6969505 for instructions on how +# to install from a subdirection +# As of Capistrano 3.3.3, you can now use the :repo_tree configuration variable, +# http://capistranorb.com/documentation/getting-started/configuration/ lock '3.6.1' set :application, ->{YAML.load_file('config/deploy.yml')[fetch(:stage)][:directory]} set :repo_url, ->{YAML.load_file('config/deploy.yml')[fetch(:stage)][:repo_url]} @@ -8,11 +12,10 @@ # ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call # Default deploy_to directory is /var/www/my_app -set :deploy_to, "/home/rails/muti/#{fetch(:stage)}" +set :deploy_to, "/home/rails/muti_tree/#{fetch(:stage)}" # Default value for :scm is :git # set :scm, :git -set :git_strategy, Capistrano::Git::SubmoduleStrategy set :repo_tree, 'src/ruby/meetings' # Default value for :format is :pretty # set :format, :pretty @@ -24,7 +27,7 @@ # set :pty, true # Default value for :linked_files is [] -set :linked_files, ['config/database.yml','config/secrets.yml','config/deploy.yml','config/environment_params.yml'] +set :linked_files, ['config/database.yml','config/secrets.yml','config/environment_params.yml'] # Default value for linked_dirs is [] set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads} @@ -35,24 +38,5 @@ # Default value for keep_releases is 5 # set :keep_releases, 5 -namespace :deploy do - desc 'Restart application' - task :restart do - on roles(:app), in: :sequence, wait: 5 do - # Your restart mechanism here, for example: - invoke 'unicorn:reload' - end - end - after :publishing, :restart - - after :restart, :clear_cache do - on roles(:web), in: :groups, limit: 3, wait: 10 do - # Here we can do anything such as: - # within release_path do - # execute :rake, 'cache:clear' - # end - end - end - - -end + + diff --git a/src/ruby/meetings/config/deploy/staging.rb b/src/ruby/meetings/config/deploy/staging.rb index c40a5bf..b525ac0 100644 --- a/src/ruby/meetings/config/deploy/staging.rb +++ b/src/ruby/meetings/config/deploy/staging.rb @@ -16,7 +16,7 @@ # server list. The second argument is a, or duck-types, Hash and is # used to set extended properties on the server. set :domain,YAML.load_file('config/deploy.yml')[fetch(:stage)][:domain] -server fetch(:domain), user: 'ubuntu', roles: %w{db web app}#, my_property: :my_value +server fetch(:domain), user: 'rails', roles: %w{db web app}#, my_property: :my_value diff --git a/src/ruby/meetings/config/environments/staging.rb b/src/ruby/meetings/config/environments/staging.rb index 564977c..8aef815 100644 --- a/src/ruby/meetings/config/environments/staging.rb +++ b/src/ruby/meetings/config/environments/staging.rb @@ -21,7 +21,7 @@ # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier diff --git a/src/ruby/meetings/config/unicorn/production.rb b/src/ruby/meetings/config/unicorn/production.rb deleted file mode 100644 index 5efeea8..0000000 --- a/src/ruby/meetings/config/unicorn/production.rb +++ /dev/null @@ -1,38 +0,0 @@ -root = "/home/rails/muti/staging/current" -working_directory root - -pid "#{root}/tmp/pids/unicorn.pid" - -stderr_path "#{root}/log/unicorn.log" -stdout_path "#{root}/log/unicorn.log" - -worker_processes 4 -timeout 30 -preload_app true - -listen '/tmp/unicorn.muti.sock', backlog: 64 - -before_fork do |server, worker| - Signal.trap 'TERM' do - puts 'Unicorn master intercepting TERM and sending myself QUIT instead' - Process.kill 'QUIT', Process.pid - end - - defined?(ActiveRecord::Base) and - ActiveRecord::Base.connection.disconnect! -end - -after_fork do |server, worker| - Signal.trap 'TERM' do - puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' - end - - defined?(ActiveRecord::Base) and - ActiveRecord::Base.establish_connection -end - -# Force the bundler gemfile environment variable to -# # reference the capistrano "current" symlink -before_exec do |_| - ENV['BUNDLE_GEMFILE'] = File.join(root, 'Gemfile') -end diff --git a/src/ruby/meetings/config/unicorn/staging.rb b/src/ruby/meetings/config/unicorn/staging.rb deleted file mode 100644 index 38c6659..0000000 --- a/src/ruby/meetings/config/unicorn/staging.rb +++ /dev/null @@ -1,38 +0,0 @@ -root = "/home/rails/muti/staging/current" -working_directory root - -pid "#{root}/tmp/pids/unicorn.pid" - -stderr_path "#{root}/log/unicorn.log" -stdout_path "#{root}/log/unicorn.log" - -worker_processes 4 -timeout 30 -preload_app true - -listen '/tmp/unicorn.muti.staging.sock', backlog: 64 - -before_fork do |server, worker| - Signal.trap 'TERM' do - puts 'Unicorn master intercepting TERM and sending myself QUIT instead' - Process.kill 'QUIT', Process.pid - end - - defined?(ActiveRecord::Base) and - ActiveRecord::Base.connection.disconnect! -end - -after_fork do |server, worker| - Signal.trap 'TERM' do - puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' - end - - defined?(ActiveRecord::Base) and - ActiveRecord::Base.establish_connection -end - -# Force the bundler gemfile environment variable to -# # reference the capistrano "current" symlink -before_exec do |_| - ENV['BUNDLE_GEMFILE'] = File.join(root, 'Gemfile') -end