Pyjoyment.Command.prefork - Pre-fork command

Usage: APPLICATION prefork [OPTIONS]

  ./myapp.py prefork
  ./myapp.py prefork -m production -p -l http://*:8080
  ./myapp.py prefork -l http://127.0.0.1:8080 -l https://[::]:8081
  ./myapp.py prefork -l 'https://*:443?cert=./server.crt&key=./server.key'
  ./myapp.py prefork -l http+unix://%2Ftmp%2Fmyapp.sock -w 12
  ./myapp.py prefork -l fcgi://127.0.0.1:9000
  ./myapp.py prefork -l http://127.0.0.1:8080 -p 127.0.0.0/8 -p fc00::/7

Options:
  -a, --accepts <number>               Number of connections for workers to
                                       accept, less up to half at random,
                                       defaults to 10000
  -b, --backlog <size>                 Listen backlog size, defaults to
                                       SOMAXCONN
  -c, --clients <number>               Maximum number of concurrent
                                       connections, defaults to 1000
  -G, --graceful-timeout <seconds>     Graceful timeout, defaults to 25.
  -I, --heartbeat-interval <seconds>   Heartbeat interval, defaults to 5
  -H, --heartbeat-timeout <seconds>    Heartbeat timeout, defaults to 50
  -h, --help                           Show this summary of available options
      --home <path>                    Path to home directory of your
                                       application, defaults to the value of
                                       PYJO_HOME or auto-detection
  -i, --inactivity-timeout <seconds>   Inactivity timeout, defaults to the
                                       value of PYJO_INACTIVITY_TIMEOUT or 30
  -k, --keep-alive-timeout <seconds>   Keep-alive timeout, defaults to the
                                       value of PYJO_KEEP_ALIVE_TIMEOUT or 5
  -l, --listen <location>              One or more locations you want to
                                       listen on, defaults to the value of
                                       PYJO_LISTEN, the port of PORT or
                                       "http://*:3000"
      --log-format <name>              Format of log messages, "text",
                                       "plain" without time and process, or
                                       "json", defaults to the value of
                                       PYJO_LOG_FORMAT or "text"
  -m, --mode <name>                    Operating mode for your application,
                                       defaults to the value of PYJO_MODE or
                                       "development"
  -P, --pid-file <path>                Path to process id file, defaults to
                                       "prefork.pid" in a temporary directory
  -p, --proxy [<network>]              Activate reverse proxy support,
                                       defaults to the value of
                                       PYJO_REVERSE_PROXY, optionally takes
                                       one or more trusted proxy addresses or
                                       networks
  -r, --requests <number>              Maximum number of requests per
                                       keep-alive connection, defaults to 100
  -S, --shutdown-delay <seconds>       Time to keep serving after INT or TERM
                                       before shutting down gracefully,
                                       defaults to 0
  -s, --spare <number>                 Temporarily spawn up to this number of
                                       additional workers, defaults to 2
  -w, --workers <number>               Number of workers, defaults to 4

Pyjoyment.Command.prefork starts applications with the Pyjo.Server.Prefork backend.

An option that is not given has the value of the environment variable of PYJO_ and its name, as PYJO_WORKERS for --workers, with the values of --listen and --proxy separated by commas, see Pyjo.GetOpt, so that the environment of a container or a platform can tune the server.

PYJO_GRACEFUL_TIMEOUT=8 PYJO_WORKERS=2 ./myapp.py prefork

This is a core command, that means it is always enabled and its code a good example for learning to build new commands, you’re welcome to fork it.

See Pyjoyment.Commands for a list of commands that are available by default.

See also

Pyjoyment, https://mojolicious.org.

Ported from Mojolicious::Command::prefork of Mojolicious 9.49.

Classes

class Pyjoyment.Command.prefork.Pyjoyment_Command_prefork(**kwargs: Any)[source]

Pyjoyment.Command.prefork inherits all attributes and methods from Pyjoyment.Command and implements the following new ones.

build_server(*args: str) → Pyjo_Server_Prefork[source]
server = prefork.build_server(*sys.argv[1:])

Build Pyjo.Server.Prefork instance from command line arguments.

description = 'Start application with pre-forking HTTP and WebSocket server'
description = prefork.description
prefork.description = 'Foo'

Short description of this command, used for the command list.

run(*args: str) → Any[source]
prefork.run(*sys.argv[1:])

Run this command.

usage = 'Usage: APPLICATION prefork [OPTIONS]\n\n  ./myapp.py prefork\n  ./myapp.py prefork -m production -p -l http://*:8080\n  ./myapp.py prefork -l http://127.0.0.1:8080 -l https://[::]:8081\n  ./myapp.py prefork -l \'https://*:443?cert=./server.crt&key=./server.key\'\n  ./myapp.py prefork -l http+unix://%2Ftmp%2Fmyapp.sock -w 12\n  ./myapp.py prefork -l fcgi://127.0.0.1:9000\n  ./myapp.py prefork -l http://127.0.0.1:8080 -p 127.0.0.0/8 -p fc00::/7\n\nOptions:\n  -a, --accepts <number>               Number of connections for workers to\n                                       accept, less up to half at random,\n                                       defaults to 10000\n  -b, --backlog <size>                 Listen backlog size, defaults to\n                                       SOMAXCONN\n  -c, --clients <number>               Maximum number of concurrent\n                                       connections, defaults to 1000\n  -G, --graceful-timeout <seconds>     Graceful timeout, defaults to 25.\n  -I, --heartbeat-interval <seconds>   Heartbeat interval, defaults to 5\n  -H, --heartbeat-timeout <seconds>    Heartbeat timeout, defaults to 50\n  -h, --help                           Show this summary of available options\n      --home <path>                    Path to home directory of your\n                                       application, defaults to the value of\n                                       PYJO_HOME or auto-detection\n  -i, --inactivity-timeout <seconds>   Inactivity timeout, defaults to the\n                                       value of PYJO_INACTIVITY_TIMEOUT or 30\n  -k, --keep-alive-timeout <seconds>   Keep-alive timeout, defaults to the\n                                       value of PYJO_KEEP_ALIVE_TIMEOUT or 5\n  -l, --listen <location>              One or more locations you want to\n                                       listen on, defaults to the value of\n                                       PYJO_LISTEN, the port of PORT or\n                                       "http://*:3000"\n      --log-format <name>              Format of log messages, "text",\n                                       "plain" without time and process, or\n                                       "json", defaults to the value of\n                                       PYJO_LOG_FORMAT or "text"\n  -m, --mode <name>                    Operating mode for your application,\n                                       defaults to the value of PYJO_MODE or\n                                       "development"\n  -P, --pid-file <path>                Path to process id file, defaults to\n                                       "prefork.pid" in a temporary directory\n  -p, --proxy [<network>]              Activate reverse proxy support,\n                                       defaults to the value of\n                                       PYJO_REVERSE_PROXY, optionally takes\n                                       one or more trusted proxy addresses or\n                                       networks\n  -r, --requests <number>              Maximum number of requests per\n                                       keep-alive connection, defaults to 100\n  -S, --shutdown-delay <seconds>       Time to keep serving after INT or TERM\n                                       before shutting down gracefully,\n                                       defaults to 0\n  -s, --spare <number>                 Temporarily spawn up to this number of\n                                       additional workers, defaults to 2\n  -w, --workers <number>               Number of workers, defaults to 4\n'
usage = prefork.usage
prefork.usage = 'Foo'

Usage information for this command, used for the help screen.