Passenger::Process Class Reference
[Apache-independent support classes and function]

Represents a single application process, as spawned by SpawnManager or by ApplicationPool::Interface::get(). More...

#include <Process.h>

List of all members.

Public Member Functions

 Process (const string &appRoot, pid_t pid, int ownerPipe, const SocketInfoMap &serverSockets, const string &detachKey, const string &connectPassword, const string &gupid, const function< void()> &destructionCallback=function< void()>())
 Construct a new Process object.
string getAppRoot () const
 Returns the application root for this application process.
pid_t getPid () const
 Returns the process ID of this application process.
string getDetachKey () const
 Returns this process's detach key.
string getConnectPassword () const
 Returns this process's connect password.
string getGupid () const
 Returns this process's gupid.
const SocketInfoMap * getServerSockets () const
 Returns a map containing all server sockets that this process listens on.
SessionPtr newSession (const StandardSession::CloseCallback &closeCallback=StandardSession::CloseCallback(), bool initiateNow=true)
 Request a new session from this application process by connecting to its main server socket.

Detailed Description

Represents a single application process, as spawned by SpawnManager or by ApplicationPool::Interface::get().


Constructor & Destructor Documentation

Passenger::Process::Process ( const string &  appRoot,
pid_t  pid,
int  ownerPipe,
const SocketInfoMap &  serverSockets,
const string &  detachKey,
const string &  connectPassword,
const string &  gupid,
const function< void()> &  destructionCallback = function<void ()>() 
) [inline]

Construct a new Process object.

Parameters:
appRoot The application root of an application. This must be a valid directory, but the path does not have to be absolute.
pid The process ID of this application process.
ownerPipe The owner pipe of this application process.
serverSockets All the server sockets that this process listens on. There must a server socket with the name 'main'.
detachKey A detach key. Used by the ApplicationPool algorithm.
connectPassword The password to use when connecting to this process. Must be valid ASCII.
gupid A string which uniquely identifies this process.
destructionCallback A callback to be called when this Process is destroyed.
Exceptions:
ArgumentException If serverSockets has no socket named 'main'.

Member Function Documentation

string Passenger::Process::getAppRoot (  )  const [inline]

Returns the application root for this application process.

See the constructor for information about the application root.

string Passenger::Process::getConnectPassword (  )  const [inline]

Returns this process's connect password.

This password is guaranteed to be valid ASCII.

string Passenger::Process::getGupid (  )  const [inline]

Returns this process's gupid.

This is like a PID, but does not rotate and is even unique over multiple servers.

SessionPtr Passenger::Process::newSession ( const StandardSession::CloseCallback &  closeCallback = StandardSession::CloseCallback(),
bool  initiateNow = true 
) [inline]

Request a new session from this application process by connecting to its main server socket.

This session represents the life time of a single request/response pair, and can be used to send the request data to the application process, as well as receiving the response data.

The use of connect() is demonstrated in the following example.

   // Request a new session from the process.
   SessionPtr session = process->newSession(...);
   
   // Send the request headers and request body data.
   session->sendHeaders(...);
   session->sendBodyBlock(...);
   // Done sending data, so we close the writer channel.
   session->shutdownWriter();

   // Now read the HTTP response.
   string responseData = readAllDataFromSocket(session->getReader());
   // Done reading data, so we close the reader channel.
   session->shutdownReader();

   // This session has now finished, so we close the session by resetting
   // the smart pointer to NULL (thereby destroying the Session object).
   session.reset();

   // We can connect to a Process multiple times. Just make sure
   // the previous session is closed.
   session = process->newSession(...);

You must close a session when you no longer need it. If you call connect() without having properly closed a previous session, you might cause a deadlock because the application process may be waiting for you to close the previous session.

Parameters:
closeCallback A function which will be called when the session has been closed.
initiateNow Whether the session should be initiated immediately. If set to false then you must call initiate() on the session before it's usable.
Returns:
A smart pointer to a Session object, which represents the created session.
Postcondition:
result->initiated() == initiateNow
Exceptions:
SystemException Something went wrong during session initiation.
IOException Something went wrong during session initiation.
boost::thread_interrupted 

The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2