Use the command line¶
Procrastinate installs a command-line tool, which allows to do some operations:
Prepare your database for procrastinate (apply the database schema)
Launch a worker
Defer a task
…
The command-line tool can be launched using:
$ procrastinate
or:
$ python -m procrastinate
Please read the included help to get familiar with its commands and parameters:
$ procrastinate --help
Usage: procrastinate [OPTIONS] COMMAND [ARGS]...
Interact with a Procrastinate app. See subcommands for details.
All arguments can be passed by environment variables:
PROCRASTINATE_UPPERCASE_NAME or PROCRASTINATE_COMMAND_UPPERCASE_NAME
(examples: PROCRASTINATE_APP, PROCRASTINATE_DEFER_UNKNOWN, ...).
Options:
-a, --app TEXT Dotted path to the Procrastinate app
-v, --verbose Use multiple times to increase verbosity
--log-format TEXT Defines the format used for logging (see https:/
/docs.python.org/3/library/logging.html#logrecor
d-attributes)
--log-format-style [%|{|$] Defines the style for the log format string (see
https://docs.python.org/3/howto/logging-
cookbook.html#use-of-alternative-formatting-
styles)
-V, --version Show the version and exit.
-h, --help Show this message and exit.
Commands:
defer Create a job from the given task, to be executed by a...
healthchecks Check the state of procrastinate.
schema Apply SQL schema to the empty database.
shell Administration shell for procrastinate.
worker Launch a worker, listening on the given queues (or all...
Avoid specifying the --app
parameter all the time¶
Procrastinate needs to know your app for most operations. in particular in the
command line interface, you’ll find yourself frequently typing
--app=dotted.path.to.app
. You can specify this one in your environment by instead
using:
$ export PROCRASTINATE_APP=dotted.path.to.app worker
As a general rule, all parameters have an environment variable equivalent, named
PROCRASTINATE_SOMETHING
where SOMETHING
is the uppercased long name of the
option, with -
replaced with _
.
Logging¶
Three different options allow you to control how the command-line tool should log events:
Verbosity controls the log level (you’ll see message of this level and above):
Flags
Environment equivalent
Log level
PROCRASTINATE_VERBOSITY=0
warning
-v
PROCRASTINATE_VERBOSITY=1
info
-vv
PROCRASTINATE_VERBOSITY=2
debug
Log format:
--log-format=
/PROCRASTINATE_LOG_FORMAT=
lets you control how the log line will be formatted. It uses%
-style placeholders by default.Log format style:
--log-format-style=
/PROCRASTINATE_LOG_FORMAT_STYLE=
lets you choose different styles for the log-format, such as{
or$
.
For more information on log formats, refer to the Python documentation