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

Class for spawning WSGI applications.

### Methods

spawn_application spawn_application

### Included Modules

Utils

### Constants

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

### Public Class methods

spawn_application(*args)

[Source]

        # File lib/phusion_passenger/wsgi/application_spawner.rb, line 29
    29:         def self.spawn_application(*args)
    30:                 @@instance ||= ApplicationSpawner.new
    31:                 @@instance.spawn_application(*args)
    32:         end

### Public Instance methods

spawn_application(app_root, lower_privilege = true, lowest_user = "nobody", environment = "production")

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 42
    42:         def spawn_application(app_root, lower_privilege = true, lowest_user = "nobody", environment = "production")
    43:                 a, b = UNIXSocket.pair
    44:                 pid = safe_fork(self.class.to_s, true) do
    45:                         a.close
    46:
    47:                         file_descriptors_to_leave_open = [0, 1, 2, b.fileno]
    48:                         NativeSupport.close_all_file_descriptors(file_descriptors_to_leave_open)
    49:                         close_all_io_objects_for_fds(file_descriptors_to_leave_open)
    50:
    51:                         run(MessageChannel.new(b), app_root, lower_privilege, lowest_user, environment)
    52:                 end
    53:                 b.close
    54:                 Process.waitpid(pid) rescue nil
    55:
    56:                 channel = MessageChannel.new(a)
    57:                 pid, socket_name, socket_type = channel.read
    58:                 if pid.nil?
    59:                         raise IOError, "Connection closed"
    60:                 end
    61:                 owner_pipe = channel.recv_io
    62:                 return Application.new(@app_root, pid, socket_name,
    63:                         socket_type, owner_pipe)
    64:         end

[Validate]