Skip to content

Commit

Permalink
Move patches out of daemon, require them after the Rails environment …
Browse files Browse the repository at this point in the history
…is loaded
  • Loading branch information
ileitch committed Oct 9, 2011
1 parent d2385fe commit bfd2c3d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
20 changes: 11 additions & 9 deletions bin/rapns
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/usr/bin/env ruby

require "optparse"
require "rapns"
require "rapns/daemon"
require 'optparse'
require 'rapns'
require 'rapns/daemon'

foreground = false
environment = ARGV[0]
banner = "Usage: rapns <Rails environment> [options]"
banner = 'Usage: rapns <Rails environment> [options]'
ARGV.options do |opts|
opts.banner = banner
opts.on("-f", "--foreground", "Run in the foreground.") { foreground = true }
opts.on("-v", "--version", "Print this version of rapns.") { puts "rapns #{Rapns::VERSION}"; exit }
opts.on("-h", "--help", "You're looking at it.") { puts opts; exit }
opts.on('-f', '--foreground', 'Run in the foreground.') { foreground = true }
opts.on('-v', '--version', 'Print this version of rapns.') { puts "rapns #{Rapns::VERSION}"; exit }
opts.on('-h', '--help', 'You\'re looking at it.') { puts opts; exit }
opts.parse!
end

Expand All @@ -20,7 +20,9 @@ if environment.nil?
exit 1
end

ENV["RAILS_ENV"] = environment
load "config/environment.rb"
ENV['RAILS_ENV'] = environment
load 'config/environment.rb'

require 'rapns/patches'

Rapns::Daemon.start(environment, foreground)
2 changes: 0 additions & 2 deletions lib/rapns/daemon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
require 'rapns/daemon/feeder'
require 'rapns/daemon/logger'

require 'rapns/daemon/patches'

module Rapns
module Daemon
class << self
Expand Down
6 changes: 0 additions & 6 deletions lib/rapns/daemon/patches.rb

This file was deleted.

6 changes: 6 additions & 0 deletions lib/rapns/patches.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if ActiveRecord::Base.configurations[Rails.env]['adapter'] == 'postgresql'
if Rails::VERSION::STRING == '3.1.0' || Rails::VERSION::STRING == '3.1.1'
STDERR.puts "[WARNING] Detected Rails #{Rails::VERSION::STRING}, patching PostgreSQLAdapter to fix reconnection bug: https://github.com/rails/rails/issues/3160."
require "rapns/patches/rails/#{Rails::VERSION::STRING}/postgresql_adapter.rb"
end
end

0 comments on commit bfd2c3d

Please sign in to comment.