This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/internal
Marc 'risson' Schmitt fc5f6d6677
root: handle SIGHUP and SIGUSR2
This is the first step to handle configuration reloading. With those
changes, it is already possible to do so, by sending a SIGUSR2 signal to
the Go server process. The next step would be to watch for changes to
configuration files and call the Restart function of the GoUnicorn
instance.

SIGHUP is catched by the go server and forwarded as-is to gunicorn,
which causes it to restart its workers. However, that does not trigger
a reload of the Django settings, probably because they are already
loaded in the master, before creating any of the worker instances.

SIGUSR2, however, can be used to spawn a new gunicorn master process,
but handling it is a bit trickier. Please refer to Gunicorn's
documentation[0] for details, especially the "Upgrading to a new binary
on the fly" section.

As we are now effectively killing the gunicorn processed launched by the
server, we need to handle some sort of check to make sure it is still
running. That's done by using the already existing healthchecks, making
them useful not only for the application start, but also for its
lifetime. If a check is failed too many times in a given time period,
the gunicorn processed is killed (if necessary) and then restarted.

[0] https://docs.gunicorn.org/en/20.1.0/signals.html

Other relevant links and documentation:

Python library handling the processing swaping upon a SIGUSR2:
https://github.com/flupke/rainbow-saddle/

Golang cannot easily check if a process exists on Unix systems:
https://github.com/golang/go/issues/34396

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
2023-04-29 00:00:45 +02:00
..
common web/admin: fix error adding users to groups (#5016) 2023-03-20 18:15:36 +01:00
config website: add documentation for AUTHENTIK_REDIS__TLS (#5349) 2023-04-23 11:37:53 +03:00
constants release: Version 2023.4 (#5283) 2023-04-18 10:45:17 +02:00
crypto internal: fix crash when port 9000 is in use (#4863) 2023-03-07 13:27:46 +01:00
debug internal: fix linting error 2023-01-09 17:17:27 +01:00
gounicorn root: handle SIGHUP and SIGUSR2 2023-04-29 00:00:45 +02:00
outpost providers/ldap: remove deprecated fields (#5154) 2023-04-21 14:10:24 +03:00
utils root: handle SIGHUP and SIGUSR2 2023-04-29 00:00:45 +02:00
web internal: fix crash when port 9000 is in use (#4863) 2023-03-07 13:27:46 +01:00