Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
Uvicorn isn't running when i execute it via a script

If i run from the terminal uvicorn main:app --reload everything works.

When putting it in a my_script.sh file with

#!/bin/bash
exec uvicorn main:app --reload

then nothing happens. Why?

I found this: Uvicorn/FastAPI executable but it seems unanswered.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can instead add a main method (more specifically, if __name__ == "__main__":) inside your existing Python script (i.e., main.py in your case) or a new Python script, where you run the uvicorn server, allowing you to set parameters, such as host, port, reload, workers, etc. (as shown here), and simply execute that Python script from inside your bash script. Have a look here for all the available options.

import uvicorn

if __name__ == "__main__":
    uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)

Edit: Since you mentioned below that you "have the script defined in the entrypoint section of docker-compose", make sure you give the exact path to the bash script, as well as it has permissions to execute. Have a look at the questions here and here. I would also suggest to take a look at the relevant FastAPI documentation.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!