Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resque prod #47

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
Expand All @@ -26,7 +25,7 @@ gem 'sdoc', '~> 0.4.0', group: :doc
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'
gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
Expand Down
9 changes: 7 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ GEM
thor (>= 0.14, < 2.0)
json (1.8.2)
jwt (1.4.1)
kgio (2.9.3)
loofah (2.0.1)
nokogiri (>= 1.5.9)
mail (2.6.3)
Expand Down Expand Up @@ -138,6 +139,7 @@ GEM
activesupport (= 4.2.1)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
raindrops (0.13.0)
rake (10.4.2)
rdoc (4.2.0)
json (~> 1.4)
Expand Down Expand Up @@ -182,7 +184,6 @@ GEM
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.10)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
Expand All @@ -195,6 +196,10 @@ GEM
uglifier (2.7.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
unicorn (4.9.0)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
vegas (0.1.11)
rack (>= 1.0.0)
web-console (2.1.2)
Expand Down Expand Up @@ -228,7 +233,7 @@ DEPENDENCIES
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
sqlite3
twilio-ruby
uglifier (>= 1.3.0)
unicorn
web-console (~> 2.0)
2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
resque: env TERM_CHILD=1 QUEUE=* bundle exec rake resque:work
1 change: 1 addition & 0 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def create
@event.schedule_bg_job
redirect_to "/?message=success#upcoming"
else
p @event
if @event.ride_id? == nil
@errors = ['Cannot find rides for departure address','Please make sure it is accurate']
@event.destroy
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/oauth2_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def callback
client_secret: ENV['UBER_SECRET'],
client_id: ENV['UBER_CLIENT_ID'],
grant_type: 'authorization_code',
redirect_uri: 'http://localhost:3000/oauth2/callback',
redirect_uri: "#{ENV['REDIRECT_URI'] || 'http://localhost:3000'}/oauth2/callback",
code: params[:code] })
access_token = response["access_token"]
refresh_token = response["refresh_token"]
Expand Down
4 changes: 0 additions & 4 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
Expand All @@ -28,8 +27,5 @@ class Application < Rails::Application
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de

# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
end
end
25 changes: 0 additions & 25 deletions config/database.yml

This file was deleted.

3 changes: 0 additions & 3 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log

# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load

# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
Expand Down
3 changes: 0 additions & 3 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,4 @@

# 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
end
3 changes: 3 additions & 0 deletions config/initializers/redis.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if ENV["REDISTOGO_URL"]
$redis = Resque.redis = Redis.new(:url => ENV["REDISTOGO_URL"])
end
29 changes: 29 additions & 0 deletions config/unicorn.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 15
preload_app true


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!

if defined?(Resque)
Resque.redis.quit
Rails.logger.info('Disconnected from Redis')
end
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

if defined?(Resque)
Rails.logger.info('Connected to Redis')
end
end
3 changes: 2 additions & 1 deletion lib/tasks/resque.rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'resque/tasks'
require 'resque/scheduler/tasks'

task "resque:setup" => :environment
task "resque:setup" => :environment
task "resque:preload" => :environment