Skip to content

Commit

Permalink
Merge pull request #384 from cbdr/puma
Browse files Browse the repository at this point in the history
Unicorn -> Puma
  • Loading branch information
Alex Tharp authored Nov 13, 2016
2 parents 3fa3803 + f3a3296 commit e7c8c5c
Show file tree
Hide file tree
Showing 20 changed files with 167 additions and 99 deletions.
24 changes: 17 additions & 7 deletions .cloud66/deploy_hooks.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
default: &default
first_thing:
- snippet: cloud66/node
target: any
target: rails
execute: true
apply_during: build_only
- command: npm install -g bower
sudo: true
target: any
target: rails
execute: true
apply_during: build_only
after_rails:
- command: cd $STACK_PATH && bundle exec pumactl -P /tmp/web_server.pid restart
target: rails
apply_during: all

development:
<<: *default
Expand All @@ -17,14 +23,15 @@ development:
execute: true
run_on: single_server
apply_during: all
sudo: false
- source: /.cloud66/scripts/rebuild_indexes.sh
destination: /tmp/rebuild_indexes.sh
target: rails
execute: true
run_on: single_server
apply_during: all
sudo: false
- command: cd $STACK_PATH && bundle exec pumactl -P /tmp/web_server.pid restart
target: rails
apply_during: all

staging:
<<: *default
Expand All @@ -35,14 +42,15 @@ staging:
execute: true
run_on: single_server
apply_during: all
sudo: false
- source: /.cloud66/scripts/rebuild_indexes.sh
destination: /tmp/rebuild_indexes.sh
target: rails
execute: true
run_on: single_server
apply_during: all
sudo: false
- command: cd $STACK_PATH && bundle exec pumactl -P /tmp/web_server.pid restart
target: rails
apply_during: all

production:
<<: *default
Expand All @@ -53,4 +61,6 @@ production:
execute: true
run_on: single_server
apply_during: all
sudo: false
- command: cd $STACK_PATH && bundle exec pumactl -P /tmp/web_server.pid restart
target: rails
apply_during: all
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ruby '2.3.1'
gem 'bower-rails', '~> 0.11.0'

# Server
gem 'unicorn', '~> 5.2.0'
gem 'puma', '~> 3.6'

# Rails
gem 'rails', '~> 5.0.0'
Expand Down
8 changes: 2 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ GEM
kaminari (0.17.0)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
kgio (2.10.0)
launchy (2.4.3)
addressable (~> 2.3)
listen (3.1.5)
Expand Down Expand Up @@ -517,6 +516,7 @@ GEM
binding_of_caller (>= 0.7)
pry (>= 0.9.11)
public_suffix (2.0.4)
puma (3.6.0)
pundit (1.1.0)
activesupport (>= 3.0.0)
rack (2.0.1)
Expand Down Expand Up @@ -561,7 +561,6 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
raindrops (0.17.0)
rake (11.3.0)
rb-fsevent (0.9.8)
rb-inotify (0.9.7)
Expand Down Expand Up @@ -672,9 +671,6 @@ GEM
uber (0.1.0)
uglifier (3.0.3)
execjs (>= 0.3.0, < 3)
unicorn (5.2.0)
kgio (~> 2.6)
raindrops (~> 0.7)
virtus (1.0.5)
axiom-types (~> 0.1)
coercible (~> 1.0)
Expand Down Expand Up @@ -770,6 +766,7 @@ DEPENDENCIES
pry-rails
pry-remote
pry-stack_explorer
puma (~> 3.6)
pundit (~> 1.1)
rack-cors (~> 0.4.0)
rack-oauth2 (~> 1.4.0)
Expand All @@ -795,7 +792,6 @@ DEPENDENCIES
transitions (~> 1.2)
turbolinks (~> 5.0.1)
uglifier (~> 3.0.3)
unicorn (~> 5.2.0)
virtus (~> 1.0.5)
yt (~> 0.28.1)

Expand Down
4 changes: 2 additions & 2 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
web: bundle exec unicorn -c ./config/unicorn.rb -E $RAILS_ENV -D
web: bundle exec puma -e $RACK_ENV -b unix:///tmp/web_server.sock --pidfile /tmp/web_server.pid -d
worker: bundle exec sidekiq -e $RAILS_ENV -q default -q mailers
custom_web: bundle exec unicorn -c ./config/unicorn.rb -E $RAILS_ENV -D
custom_web: bundle exec puma -e $RACK_ENV -b unix:///tmp/web_server.sock --pidfile /tmp/web_server.pid -d
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

Bundler.require(:tasks)
require File.expand_path('../config/application', __FILE__)
require_relative 'config/application'

Cortex::Application.load_tasks
2 changes: 1 addition & 1 deletion bin/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
29 changes: 29 additions & 0 deletions bin/update
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils

# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end

chdir APP_ROOT do
# This script is a way to update your development environment automatically.
# Add necessary update steps to this file.

puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')

puts "\n== Updating database =="
system! 'bin/rails db:migrate'

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'

puts "\n== Restarting application server =="
system! 'bin/rails restart'
end
3 changes: 2 additions & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
require_relative 'config/environment'

run Rails.application
6 changes: 4 additions & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
require File.expand_path('../boot', __FILE__)
require_relative 'boot'

require 'rails/all'
require 'elasticsearch/rails/instrumentation'
Bundler.require(:default, Rails.env)

Bundler.require(*Rails.groups)

module Cortex
class Application < Rails::Application
Expand Down
5 changes: 2 additions & 3 deletions config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)

require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
require 'bundler/setup'

# Cache requires
require 'bootscale/setup'
9 changes: 9 additions & 0 deletions config/cable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
development:
adapter: async

test:
adapter: async

production:
adapter: redis
url: redis://localhost:6379/1
2 changes: 1 addition & 1 deletion config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Load the Rails application.
require File.expand_path('../application', __FILE__)
require_relative 'application'

# Initialize the Rails application.
Cortex::Application.initialize!
5 changes: 4 additions & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
config.action_controller.perform_caching = false

# Print deprecation notices to the Rails logger.
#config.active_support.deprecation = :log
config.active_support.deprecation = :log

# Raise an error on page load if there are pending migrations
config.active_record.migration_error = :page_load
Expand All @@ -24,6 +24,9 @@
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
config.assets.quiet = true

# config.file_watcher = ActiveSupport::EventedFileUpdateChecker

if ENV['DEPLOYED']
config.cache_store = :redis_store, ENV['CACHE_URL']
Expand Down
31 changes: 10 additions & 21 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@
config.consider_all_requests_local = false
config.action_controller.perform_caching = true

# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true

# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_files = false
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

# Compress JavaScripts and CSS.
config.assets.js_compressor = Uglifier.new(:mangle => false)
Expand All @@ -29,16 +23,15 @@
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false

# Generate digests for assets URLs.
config.assets.digest = true

# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'

# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx

# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true

Expand All @@ -47,7 +40,7 @@
config.log_level = :debug

# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
config.log_tags = [ :request_id ]

# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
Expand All @@ -58,23 +51,19 @@
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
config.action_controller.asset_host = ENV['ASSET_HOST']

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# config.assets.precompile += %w( search.js )

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found).
config.i18n.fallbacks = true

# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify

# Disable automatic flushing of the log to improve performance.
# config.autoflush_log = false

# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new

# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false

Paperclip.options[:command_path] = '/usr/local/bin/'

config.paperclip_defaults = {
Expand Down
6 changes: 6 additions & 0 deletions config/initializers/application_controller_renderer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Be sure to restart your server when you modify this file.

# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )
5 changes: 5 additions & 0 deletions config/initializers/cookies_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Be sure to restart your server when you modify this file.

# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :json
23 changes: 23 additions & 0 deletions config/initializers/new_framework_defaults.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 5.0 upgrade.
#
# Once upgraded flip defaults one by one to migrate to the new default.
#
# Read the Rails 5.0 release notes for more info on each option.

# Enable per-form CSRF tokens. Previous versions had false.
Rails.application.config.action_controller.per_form_csrf_tokens = false

# Enable origin-checking CSRF mitigation. Previous versions had false.
Rails.application.config.action_controller.forgery_protection_origin_check = false

# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
# Previous versions had false.
ActiveSupport.to_time_preserves_timezone = false

# Require `belongs_to` associations by default. Previous versions had false.
Rails.application.config.active_record.belongs_to_required_by_default = false

# Do not halt callback chains when a callback returns false. Previous versions had true.
ActiveSupport.halt_callback_chains_on_return_false = true
2 changes: 1 addition & 1 deletion config/initializers/wrap_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
wrap_parameters format: [:json]
end

# To enable root element in JSON for ActiveRecord objects.
Expand Down
Loading

0 comments on commit e7c8c5c

Please sign in to comment.