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.
Main service implementation managing the tornado.web.Application and taking care of configuration.
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.
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 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 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 the command line arguments to set different configuration values.
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.