Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document server hooks in a custom application #3214

Merged
merged 1 commit into from
May 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/source/custom.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ a custom Application:
:start-after: # See the NOTICE for more information
:lines: 2-

Using server hooks
------------------

If you wish to include server hooks in your custom application, you can specify a function in the config options. Here is an example with the `pre_fork` hook:

.. code-block:: python

def pre_fork(server, worker):
print(f"pre-fork server {server} worker {worker}", file=sys.stderr)

# ...
if __name__ == '__main__':
options = {
'bind': '%s:%s' % ('127.0.0.1', '8080'),
'workers': number_of_workers(),
'pre_fork': pre_fork,
}


Direct Usage of Existing WSGI Apps
----------------------------------

Expand Down