https://pantsbuild.org/ logo
#general
Title
# general
a

ambitious-actor-36781

11/08/2021, 12:44 AM
how are you meant to turn something that runs from another script (e.g.
gunicorn
) into a
.pex
? setting
script="gunicorn"
works... but doesn't allow specifying the
myproject.wsgi
argument.
f

fast-nail-55400

11/08/2021, 12:51 AM
Maybe have a stub script for each service that calls into common setup code that invokes gunicorn? (That is what we do at my company for our Django servers.)
👍 1
f

flat-zoo-31952

11/08/2021, 1:01 AM
You can also just use the entry point exported by gunicorn. This works for things like gunicorn that use an defined entry point to create scripts (https://github.com/benoitc/gunicorn/blob/master/setup.py#L116). I doubt this would work for django or something that doesn't use that mechanism. so you'd have something like...
Copy code
pex_binary(
    name="app",
    dependencies=[":lib" ,"//:gunicorn"],
    entry_point="gunicorn.app.wsgiapp:run",
    ...
)
And then you could run this like
./app.pex $GUNICORN_OPTIONS <http://your.gunicorn.app:entry_point|your.gunicorn.app:entry_point>
a

ambitious-actor-36781

11/08/2021, 1:19 AM
@flat-zoo-31952 Yeah, this is where I'm at. But I feel like that's "broken". as it only ever works if you provide
<http://your.gunicorn.app:entry_point|your.gunicorn.app:entry_point>
as the command line argument.
@fast-nail-55400 a stub shell script? Is there a way to make the
.pex
run this?
f

fast-nail-55400

11/08/2021, 1:25 AM
No, a stub Python script.
h

happy-kitchen-89482

11/08/2021, 1:26 AM
To clarify, are you wanting to bake arguments into the pex?
a

ambitious-actor-36781

11/08/2021, 1:27 AM
yes. I think
./django-app.pex
should require 0 additional augments to run, even if it's a basic runtime configuration.
e

enough-analyst-54434

11/08/2021, 1:33 AM
a

ambitious-actor-36781

11/08/2021, 1:36 AM
ah yes. that's the one.
in the meantime, I've found a workaround along the same line as @fast-nail-55400's suggestion
5 Views