Permalink
Browse files

- If spawning fails and Passenger is running inside unit tests, then …

…print exception backtraces.

- Fix the Rails stubs.
- Fix a regression introduced by the page caching fix.
- Reestablish ActiveRecord database connection if the database was connected to during environment.rb. Should fix issue #14.
  • Loading branch information...
1 parent bf379a1 commit c4ae459ed1f7f7617b04c360a03b4e7fa5bc3c5a @FooBarWidget FooBarWidget committed Apr 15, 2008
@@ -182,6 +182,9 @@ def initialize_server # :nodoc:
lower_privilege! if @lower_privilege
preload_application
rescue StandardError, ScriptError, NoMemoryError => e
+ if ENV['TESTING_PASSENGER'] == '1'
+ print_exception(self.class.to_s, e)
+ end
client.write('exception')
client.write_scalar(marshal_exception(e))
return
@@ -232,7 +235,7 @@ def preload_application
Rails::Initializer.run(:set_load_path)
end
require 'config/environment'
- if ActionController::Base.page_cache_directory.empty?
+ if ActionController::Base.page_cache_directory.blank?
ActionController::Base.page_cache_directory = "#{RAILS_ROOT}/public"
end
if defined?(ActionController::Dispatcher) \
@@ -279,6 +282,13 @@ def start_request_handler
$0 = "Rails: #{@app_root}"
reader, writer = IO.pipe
begin
+ # Re-establish connection if a connection was established
+ # in environment.rb. This prevents us from concurrently
+ # accessing the same MySQL connection handle.
+ if defined?(::ActiveRecord::Base) && ::ActiveRecord::Base.connected?
+ ::ActiveRecord::Base.establish_connection
+ end
+
handler = RequestHandler.new(reader)
client.write(Process.pid, handler.socket_name,
handler.using_abstract_namespace?)
View
@@ -14,6 +14,7 @@ int main() {
tut::runner.get().set_callback(&reporter);
signal(SIGPIPE, SIG_IGN);
setenv("RAILS_ENV", "production", 1);
+ setenv("TESTING_PASSENGER", "1", 1);
try {
tut::runner.get().run_tests();
} catch (const std::exception &ex) {
@@ -1,5 +1,9 @@
module ActionController
class Base
+ def self.page_cache_directory
+ nil
+ end
+
def self.page_cache_directory=(dir)
end
end
@@ -0,0 +1,7 @@
+class ActiveRecord
+ class Base
+ def self.connected?
+ return false
+ end
+ end
+end

0 comments on commit c4ae459

Please sign in to comment.