Class Server.

Inherits Garbage

The Server class performs the server startup functions that are common to most/all Archiveopteryx servers. The functions are performed in a fixed order - you call setup( x ) to continue up to stage x, then return.

Server::Server( const char * name, int argc, char * argv[] )

Constructs a Server for name. name will be used for the pid file, etc. argc and argv are parsed to find command-line options.

void Server::configuration()

Reads server configuration, either from the default config file or from the one supplied in argc.

void Server::files()

Closes all files except stdout and stderr. Attaches stdin to /dev/null in case something uses it. stderr is kept open so that we can tell our daddy about any disasters.

void Server::fork()

Forks the server as required by -f and the configuration variable server-processes.

If -f is specified, the parent exits in this function and does not return from this function.

As many processes as specified by server-processes return.

static void Server::killChildren()

Called by signal handling to kill any children started in fork().

void Server::logSetup()

Creates the global logging context, and sets up a LogClient if no Logger has been created already.

This also creates the Loop object, so that the LogClient doesn't feel alone in the world, abandoned by its parents, depressed and generally bad.

void Server::logStartup()

Logs the startup details. By this time, the logger must be in working order.

void Server::loop()

Initializes the global event loop.

void Server::maintainChildren()

Maintains the requisite number of children. Only child processes return from this function.

static EString Server::name()

This static function returns the name of the application. Is server the right way to publicise this name?

void Server::nameResolution()

Resolves any domain names used in the configuration file before we chroot.

void Server::pidFile()

Writes the server's pid to an almost hardcoded pidfile. We don't lock the file, since most of these servers don't have a problem with multiple instances of themselves. The pidfile is just a convenience for tools like start-stop-daemon.

void Server::run()

Finishes setup and runs the main loop of the server.

void Server::secure()

Loses all rights. Dies with an error if that isn't possible, or if anything fails.

void Server::setChrootMode( ChrootMode mode )

Notifies the Server that it is to chroot according to mode. If mode is JailDir, secure() will chroot into the jail directory and check that '/' is inaccesssible. If mode is LogDir, secure() will chroot into the logfile directory, where the server hopefully can access the logfile.

void Server::setup( Stage s )

Performs server setup for each stage up to but NOT including s.

static bool Server::useCache()

Returns true if this server is configured to cache this and that, and false if it shouldn't cache.

Running without cache is a debugging aid.

This web page based on source code belonging to The Archiveopteryx Developers. All rights reserved.