This change make it clear what is configuration file for Gunicorn.
Using a filename with an extension different than a python extension
was never supported. Also it gives us some room for a proper config file.
* load application from factory function
Use `ast.parse` to validate that the string passed to the CLI is either
an attribute name or a function call. Use `ast.literal_eval` to parse
any positional and keyword arguments to the function. Call the function
to get the real application.
Co-authored-by: Connor Brinton <connor.brinton@gmail.com>
* test coverage for util.import_app
* document app factory pattern
This allows you to specify that you want setproctitle installed so that
gunicorn can set meaningful process names at install time or in a
requirements file.
There's no need for PIDFile=, especially not for Type=notify services.
systemd knows the correct pid of the process it manages.
No need for the `--bind` option either, since gunicorn supports the
LISTEN_FDS environment variable and will use all of the sockets that systemd
provides. This way, it's also more flexible, since we can specify several
sockets in a .socket unit.
The .socket unit should specify User=www-data so that nginx can connect to the socket.
The service (gunicorn process) will inherit the file descriptor so it
doesn't even need permissions for the socket (it's nginx which needs
permissions).
tmpfiles.d is not needed.
replace ExecStop=/bin/kill with KillMode=mixed
* add systemd sd_notify support
roughly based on sd_notify() from systemd and https://github.com/bb4242/sdnotify
only implements `READY=1` and `STATUS=Gunicorn arbiter booted` of the
protocol in the arbiter. in the future, reloads can be notified, and
possibly also other statuses.
see https://www.freedesktop.org/software/systemd/man/sd_notify.html for
more info
sd_notify() is a noop when not run in a systemd service (i.e
NOTIFY_SOCKET environment variable is not set)