pythoninthegrass / python_template

It's dangerous to go alone
The Unlicense
12 stars 6 forks source link

Webdev - Django #78

Open JonasFiechter opened 7 months ago

JonasFiechter commented 7 months ago

Hello again @pythoninthegrass I took the first item of TODO webdev task as we talk before, and I have some questions about the procedure.

I was able to run both django projects with direct runserver command and docker container as well.

But I'm not sure about how was these web-templates supposed to run within the entire application since I couldn't run it using startup.sh

if it's not inconvenient I could send you my discord and discuss the details better.

Best regards;

pythoninthegrass commented 6 months ago

@JonasFiechter ! Totally dropped the ball on this.

Currently don't have the bandwidth to work on this unless its async (i.e., setup github discussion or discord chat-only.)

What's the error you get if you run startup.sh? Might need to run via bash -vx startup.sh.

JonasFiechter commented 6 months ago

Hi @pythoninthegrass, that's totally fine!;

About the error well, I took a look into startup.sh and saw a gunicorn call: gunicorn -w 2 -k uvicorn.workers.UvicornWorker main:app

    [2023-12-21 13:21:50 -0300] [621892] [ERROR] Exception in worker process
    Traceback (most recent call last):
    ............
    ModuleNotFoundError: No module named 'main'
    [2023-12-21 13:21:50 -0300] [621892] [INFO] Worker exiting (pid: 621892)

I bet is not so complicated to solve, but my question goes beyond this, I want to understand how entire application should work to help provisioning these applications that comes with it. Maybe a basic explanation about how it works is enough to start contributing :grin:

pythoninthegrass commented 6 months ago

Fixed startup.sh error handling for args and added a boilerplate FastAPI app in this commit: https://github.com/pythoninthegrass/python_template/commit/882079a3d82d1ccdd466e51ebc8faf141803f538

As for what the gunicorn stuff does on servers not using Django:

  • gunicorn: This is the command to start the Gunicorn server. Gunicorn is a Python WSGI HTTP server for UNIX.
  • w 2: This option sets the number of worker processes. In this case, there will be 2 workers.
  • k uvicorn.workers.UvicornWorker: This option sets the type of workers to use. In this case, Uvicorn workers are used. Uvicorn is a lightning-fast ASGI server implementation, using uvloop and httptools.
  • main:app: This is the location of the application that Gunicorn will serve. main is the Python module (i.e., the Python file), and app is the application object within that module.