Pyjoyment.Command.daemon - Daemon command

Usage: APPLICATION daemon [OPTIONS]

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

Options:
  -b, --backlog <size>                 Listen backlog size, defaults to
                                       SOMAXCONN
  -c, --clients <number>               Maximum number of concurrent
                                       connections, defaults to 1000
  -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, --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

Pyjoyment.Command.daemon starts applications with the Pyjo.Server.Daemon backend.

An option that is not given has the value of the environment variable of PYJO_ and its name, as PYJO_CLIENTS for --clients, 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_CLIENTS=100 ./myapp.py daemon

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::daemon of Mojolicious 9.49.

Classes

class Pyjoyment.Command.daemon.Pyjoyment_Command_daemon(**kwargs: Any)[source]

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

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

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

description = 'Start application with HTTP and WebSocket server'
description = daemon.description
daemon.description = 'Foo'

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

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

Run this command.

usage = 'Usage: APPLICATION daemon [OPTIONS]\n\n  ./myapp.py daemon\n  ./myapp.py daemon -m production -p -l http://*:8080\n  ./myapp.py daemon -l http://127.0.0.1:8080 -l https://[::]:8081\n  ./myapp.py daemon -l \'https://*:443?cert=./server.crt&key=./server.key\'\n  ./myapp.py daemon -l http+unix://%2Ftmp%2Fmyapp.sock\n  ./myapp.py daemon -l fcgi://127.0.0.1:9000\n  ./myapp.py daemon -l http://127.0.0.1:8080 -p 127.0.0.0/8 -p fc00::/7\n\nOptions:\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  -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, --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'
usage = daemon.usage
daemon.usage = 'Foo'

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