PythonNest / PyNest

PyNest is a Python framework built on top of FastAPI that follows the modular architecture of NestJS
https://pythonnest.github.io/PyNest
MIT License
643 stars 45 forks source link

Permission denied when running the example Application locally [Ubuntu] #26

Closed khaledadrani closed 5 months ago

khaledadrani commented 6 months ago

Hello, I have cloned the repository in an Ubuntu system (Ubuntu 22.04.3 LTS) and installed it locally in a virtual environment. I created a sample application and tried running the app:

pynest create-nest-app -n my_app
cd my_app
python main.py

I had this issue:

INFO:     Will watch for changes in these directories: ['/home/..../..../PyNest/my_app']
ERROR:    [Errno 13] Permission denied

After some investigation, the quick fix was to change the port in the generated main.py file from "80" to "8000" for example. The reason was that "80" is a privileged port.

I believe this may present an inconvenience for those who are trying the framework for the first time. A long term fix is to implement configuration management (APP_HOST, APP_PORT for example) that can change depending on the environment.

Did anyone else have this issue?

ItayTheDar commented 6 months ago

I also faced that error when trying to run an integration test using github actions but didn't realize that it is related to the port. Thanks for raising this issue! I believe that the solution will be to change documentation and that the auto generate port will be other than 80. What do you mean by by APP_HOST? an environment varible?

JEub commented 6 months ago

I had a similar issue.

Instead of using

python main.py

use:

uvicorn app:app --host 0.0.0.0 --port 8080 --reload

Alternatively, change the port in main.py to use an alternative port (like 8080).

I suspect it would be easiest to have the main file run on port 8080 instead of having users directly access uvicorn.

khaledadrani commented 6 months ago

I also faced that error when trying to run an integration test using github actions but didn't realize that it is related to the port. Thanks for raising this issue! I believe that the solution will be to change documentation and that the auto generate port will be other than 80. What do you mean by by APP_HOST? an environment varible?

@ItayTheDar What I mean is to add configuration management. For example, in Django, there is a settings file which contains all the common parameters you need for your project. I believe PyNest needs to standardize such stuff too.

@JEub Yes, I did like what you suggested and it worked as a workaround. But I believe the configuration should be accessible through a configuration management / configuration file/ configuration class etc

I can close this issue but let me first know if "configuration management" should be addressed?

ItayTheDar commented 5 months ago

@khaledadrani sorry for the late response. Indeed configuration management should be addressed. I will open pr on that ASAP. Thank you for that! I would be happy to tag you as a reviewer so you could add your perspective on how things should handled :)

khaledadrani commented 5 months ago

@ItayTheDar Yes, you can put me as a reviewer. I will be happy to help :)