Class PhusionPassenger::WSGI::ApplicationSpawner
In: lib/phusion_passenger/wsgi/application_spawner.rb
Parent: Object

Class for spawning WSGI applications.

Methods

Included Modules

Utils

Constants

REQUEST_HANDLER = File.expand_path(File.dirname(__FILE__) + "/request_handler.py")

Public Class methods

[Source]

    # File lib/phusion_passenger/wsgi/application_spawner.rb, line 40
40:         def self.spawn_application(*args)
41:                 @@instance ||= ApplicationSpawner.new
42:                 @@instance.spawn_application(*args)
43:         end

Public Instance methods

Spawn an instance of the given WSGI application. When successful, an Application object will be returned, which represents the spawned application.

Raises:

  • AppInitError: The WSGI application raised an exception or called exit() during startup.
  • SystemCallError, IOError, SocketError: Something went wrong.

[Source]

    # File lib/phusion_passenger/wsgi/application_spawner.rb, line 53
53:         def spawn_application(options)
54:                 a, b = UNIXSocket.pair
55:                 pid = safe_fork(self.class.to_s, true) do
56:                         a.close
57:                         
58:                         file_descriptors_to_leave_open = [0, 1, 2, b.fileno]
59:                         NativeSupport.close_all_file_descriptors(file_descriptors_to_leave_open)
60:                         close_all_io_objects_for_fds(file_descriptors_to_leave_open)
61:                         
62:                         run(MessageChannel.new(b), options)
63:                 end
64:                 b.close
65:                 Process.waitpid(pid) rescue nil
66:                 
67:                 channel = MessageChannel.new(a)
68:                 return AppProcess.read_from_channel(channel)
69:         end

[Validate]