Class | PhusionPassenger::ClassicRails::FrameworkSpawner
In: | lib/phusion_passenger/classic_rails/framework_spawner.rb
Parent: | AbstractServer

This class is capable of spawning Ruby on Rails application instances quickly. This is done by preloading the Ruby on Rails framework into memory, before spawning the application instances.

A single FrameworkSpawner instance can only hold a single Ruby on Rails framework version. So be careful when using FrameworkSpawner: the applications that you spawn through it must require the same RoR version. To handle multiple RoR versions, use multiple FrameworkSpawner instances.

FrameworkSpawner uses ApplicationSpawner internally.

Note: FrameworkSpawner may only be started asynchronously with AbstractServer#start. Starting it synchronously with AbstractServer#start_synchronously has not been tested.

### Methods

new reload spawn_application start

### Included Modules

Utils

### Classes and Modules

Class PhusionPassenger::ClassicRails::FrameworkSpawner::Error

### Public Class methods

new(options = {})

Creates a new instance of FrameworkSpawner.

Extra supported options:

- `framework_version`: The Ruby on Rails version to use. It is not checked whether this version is actually installed.

All other options will be passed on to ApplicationSpawner and RequestHandler.

Note that the specified Rails framework will be loaded during the entire life time of the FrameworkSpawner server. If you wish to reload the Rails framework‘s code, then restart the server by calling AbstractServer#stop and AbstractServer#start.

### Public Instance methods

reload(app_group_name = nil)

Remove the cached application instances at the given group name. If nil is specified as group name, then all cached application instances will be removed, no matter the group name.

Long description: Application code might be cached in memory by a FrameworkSpawner. But once it a while, it will be necessary to reload the code for an application, such as after deploying a new version of the application. This method makes sure that any cached application code is removed, so that the next time an application instance is spawned, the application code will be freshly loaded into memory.

Raises:

- FrameworkSpawner::Error: The FrameworkSpawner server exited unexpectedly.

spawn_application(options = {})

Spawn a RoR application using the Ruby on Rails framework version associated with this FrameworkSpawner. When successful, an Application object will be returned, which represents the spawned RoR application.

All options accepted by ApplicationSpawner.new and RequestHandler.new are accepted.

FrameworkSpawner will internally cache the code of applications, in order to speed up future spawning attempts. This implies that, if you‘ve changed the application‘s code, you must do one of these things:

- Restart this FrameworkSpawner by calling AbstractServer#stop, then AbstractServer#start.
- Reload the application by calling reload with the correct app_root argument.

Raises:

- AbstractServer::ServerNotStarted: The FrameworkSpawner server hasn‘t already been started.
- AppInitError: The application raised an exception or called exit() during startup.
- ApplicationSpawner::Error: The ApplicationSpawner server exited unexpectedly.
- FrameworkSpawner::Error: The FrameworkSpawner server exited unexpectedly.

start()

Overrided from AbstractServer#start.

May raise these additional exceptions:

- FrameworkInitError: An error occurred while loading the specified Ruby on Rails framework.
- FrameworkSpawner::Error: The FrameworkSpawner server exited unexpectedly.

[Validate]