slowdown.__main__
– The implementation of the startup script¶
This module contains the configuration schema and the startup script implementation of the Slowdown Server:
usage: slowdown [-h] [-f FILE] [-u USER] [--home DIRECTORY]
[--root DIRECTORY] [--init] [-v[v[v]] | -q]
Examples:
# Read the configuration from the command line and profile
slowdown.__main__.main()
# Specify some parameters.
# Those parameters can be used to override the configuration in the
# config file.
slowdown.__main__.main(
# Home directory, including bin, etc, lib, logs, var folders.
home='PATH/TO/HOME/DIRECTORY',
# the working directory
root='PATH/TO/ROOT/DIRECTORY', # probably $HOME/var
# the execution user
user='USER', # probably nobody
# The log level
# 0 - quiet
# 1 - logging.ERROR
# 2 - logging.INFO (default)
# 3 - logging.DEBUG
verbose=0 or 1 or 2 or 3
)
# Use string instead of config file.
slowdown.__main__.main(
config='''
<routers>
<router ALL>
pattern ^(?P<MYHOST>.*)$$
<host MYHOST>
pattern ^(?P<MYPATH>/.*)$$
<path MYPATH>
handler MY.PACKAGE
accesslog /PATH/TO/access-%Y%m.log
errorlog /PATH/TO/error-%Y%m.log
</path>
</host>
</router>
</routers>
<servers>
<http MYSERVERS>
address 127.0.0.1:8080
router ALL
</http>
</servers>
'''
)
-
class
slowdown.__main__.
Application
¶ A runtime object created by the __main__.main function that contains configuration information from the command line, profile, and the arguments in the __main__.main function.
-
fs
: slowdown.fs.FS¶ The FS object to indicate a specific filesystem that contains static files and scripts.
-
modules
: dict¶ The attribute holds modules specified in the
<modules>
section and registered with<path>handler MODULE</path>
of the configration.
-
opts
¶ The active application options.
-
args
¶ The original arguments from command line.
-
cfg
¶ The original configuration.
-
exit
(*args)¶ Stop servers and exit the program.
-
-
class
slowdown.__main__.
Handler
(application, router)¶ This class is used to handle the HTTP requests that arrive at the gevent.server.Server .
-
__call__
(rw)¶ Call self as a function.
-
-
slowdown.__main__.
main
(config: str = None, home: str = None, root: str = None, user: str = None, proc: str = None, verbose: int = 2) → None¶
-
class
slowdown.__main__.
MatchResult
(host, path_info, router_section, host_section, path_section)¶ Returned by Router.__call__() when a package is matched.
-
host
¶ matched host
-
path_info
¶ matched path_info
-
router_section
¶ the matching <router> configuration section
-
host_section
¶ the matching <host> configuration section
-
path_section
¶ the matching <path> configuration section
-
-
class
slowdown.__main__.
HTTPRWPair
(socket, reader, environ)¶ Enhances gevent.socket.socket by supporting buffering file interfaces and the HTTP/1.1 protocol.
-
match
: MatchResult¶ The matching configuration.
-
accesslog
: slowdown.logging.Logger¶ The access logger object.
-
errorlog
: slowdown.logging.Logger¶ The error logger object.
-