Service

A Service is the main element of a supercell application. It will instanciate the supercell.api.Environment and parse the configuration files as well as the command line. In the final step the tornado.web.Application is created and bound to a socket.

class supercell.api.service.Service[source]

Main service implementation managing the tornado.web.Application and taking care of configuration.

bootstrap()[source]

Implement this method in order to manipulate the configuration paths, e.g..

config[source]

Assemble the configration files and command line arguments in order to finalize the service’s configuration. All configuration values can be overwritten by the command line.

environment[source]

The default environment instance.

get_app()[source]

Create the tornado.web.Appliaction instance and return it.

In this method the Service.bootstrap() is called, then Service.run() will initialize the app.

initialize_logging()[source]

Initialize the python logging system.

It is difficult to check whether the logging system is already initialized, so we are currently only checking if a TimedRotatingFileHandler has already been added to the root logger. This should only be necessary when running unittests though.

main()[source]

Main method starting a supercell process.

This will first instantiate the tornado.web.Application and then bind it to the socket. There are two possibilities to bind to a socket: either by binding to a certain port and address as defined by the configuration (the port and address configuration settings) or by the socketfd command line parameter.

The latter is mainly used in combination with Circus (http://circus.readthedocs.org/). There you would bind the socket from circus and start the worker processes by binding to the file descriptor.

parse_command_line()[source]

Parse the command line arguments to set different configuration values.

parse_config_files()[source]

Parse the config files and return the config object, i.e. the tornado.options.options instance. For each entry in the Environment.config_file_paths() it will check for a general config.py and then for a file named as defined by Environment.config_name.

So if the config file paths are set to [‘/etc/myservice’, ‘./etc/’] the following files are parsed:

/etc/myservice/config.cfg
/etc/myservice/user_hostname.cfg
./etc/config.cfg
./etc/user_hostname.cfg

Note

By default we disable the tornado.log module, you can enable this though using by setting the logging config to some valid log level string.

run()[source]

Implement this method in order to add handlers and managed objects to the environment, before the app is started.

slog[source]

Initialize the logging and return the logger.

Read the Docs v: v0.4.0
Versions
latest
v0.4.0
v0.3.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.