-
-
Notifications
You must be signed in to change notification settings - Fork 289
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
Documentation for #569 #574
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4758f3d
Adding recipes file to index
jakethedev bf1a674
Documenting Gunicorn usage with PEX
jakethedev e773e3e
Note explaining common error with -c usage
jakethedev 85a400b
Update info to include console_scripts and a docs link
jakethedev acd81d5
Removing bad approach to gunicorn as a dep
jakethedev e32bf50
Simplify gunicorn invocation at build time
jakethedev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,5 @@ Guide: | |
|
||
whatispex | ||
buildingpex | ||
recipes | ||
api/index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.. _recipes: | ||
|
||
PEX Recipes and Notes | ||
===================== | ||
|
||
Gunicorn and PEX | ||
---------------- | ||
|
||
Normally, to run a wsgi-compatible application with Gunicorn, you'd just | ||
point Gunicorn at your application, tell Gunicorn how to run it, and you're | ||
ready to go - but if your application is shipping as a PEX file, you'll have | ||
to bundle Gunicorn as a dependency and set Gunicorn as your entry point. Gunicorn | ||
can't enter a PEX file to retrieve the wsgi instance, but that doesn't prevent | ||
the PEX from invoking Gunicorn. | ||
|
||
This retains the benefit of zero `pip install`'s to run your service, but it | ||
requires a bit more setup as you must ensure Gunicorn is packaged as a dependency. | ||
The following snippets assume Flask as the wsgi framework, Django setup should be | ||
similar: | ||
|
||
.. code-block:: bash | ||
|
||
$ pex flask gunicorn myapp -e gunicorn.app.wsgiapp -o ~/service.pex | ||
|
||
Once your pex file is created, you need to make sure to pass your wsgi app | ||
instance name to the CLI at runtime for Gunicorn to know how to hook into it, | ||
configuration can be passed in the same way: | ||
|
||
.. code-block:: bash | ||
|
||
$ service.pex myapp:appinstance -c /path/to/gunicorn_config.py | ||
|
||
And there you have it, a fully portable python web service. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about this - one last edit please:
pex flask gunicorn myapp -c gunicorn -o ~/service.pex
.I do not know gunicorn and the
-e
seemed suspiciously manual for something that is presumably gunicorn bread and butter. My discovery process:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh... I spent an embarrassing amount of time researching/asking questions regarding executing a specific module under gunicorn. And I'm glad it can be this simple. I hadn't seen a line of docs on
entry_points
until our chat here, even after digging deep into the python docs on setuputils. Now knowing about it, it's aggressively obvious in the Gunicorn setup file 🤕This PR has been a journey of enlightenment.
So that totally works like a charm and simplifies a huge pile of assumptions I've had about the way I've been hot-wiring Gunicorn. Update commit inbound.