Skip to content

Commit

Permalink
Merge pull request benoitc#3214 from boxydog/doc_prefork
Browse files Browse the repository at this point in the history
Document server hooks in a custom application
  • Loading branch information
benoitc authored May 22, 2024
2 parents 5b68c17 + 0f20019 commit 9802e21
Showing 1 changed file with 19 additions and 0 deletions.
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

0 comments on commit 9802e21

Please sign in to comment.