Closed Cory-Watson closed 2 years ago
Please @ me if you need any additional info to help reproduce. Thanks!
Turns out this wasn't a problem with gunicorn. Systemd wasn't sourcing the relevant ssh config.
Thought the ssh config was the problem, but turns out I was wrong... 🤷 Sorry for the premature close
This was not an issue with gunicorn/uvicorn.
Turns out I just needed to make sure to pass the needed PATH into the systemd service file. I think I may have been overwriting the PATH env variable with the following line out of my service file.
Environment="PATH=/opt/rtbh-python/env/bin"
Adding the needed PATH components seemed to have fixed the problem.
Environment="PATH=/opt/rtbh-python/env/bin:/bin:/sbin"
Possibly related to #1059 and #1908
I'm working on developing an API for an existing (CLI based) python app I've written. I'm using fastapi + uvicorn + gunicorn + nginx to expose the API.
When I manually run the
gunicorn
command everything works as expected, but when I run it as a systemd service some of the API calls return a 500 error. What really puzzles me is that it's only SOME of my API calls that are producing this behavior.Simplified Example
Running gunicorn from the CLI on the server
Hitting the API from the client side
Now when I run the gunicorn service via systemd this same API call instantly returns a 500 error. Just in case it might be relevant, when it's working (i.e. when I run the
gunicorn
command manually) the API usually has to chew on the request for a little while, but with the systemd setup it instantly fails with a 500.systemd service file
Same thing happens on the
/docs
page of the API.Oddly enough, other API calls work just fine...
full_gunicorn_debug.log
Looking at this snippet from the debug log it appears at face value to just be an error with my code or uvicorn (which may be the case), but I can run
gunicorn
/uvicorn
manually or run the same code in the python REPL locally and it works fine.Running the same thing locally in the REPL
HELP??