mirror of
https://github.com/YunoHost-Apps/FastAPI_ynh.git
synced 2024-09-03 18:36:00 +02:00
définition du root_path via uvicorn
This commit is contained in:
parent
2fe22d9d44
commit
1525e652af
4 changed files with 13 additions and 2 deletions
|
@ -1,9 +1,12 @@
|
|||
import os
|
||||
from typing import Union
|
||||
|
||||
from fastapi import FastAPI
|
||||
|
||||
app = FastAPI(root_path="__PATH__")
|
||||
UVICORN_ROOT_PATH = os.environ.get('UVICORN_ROOT_PATH')
|
||||
|
||||
#app = FastAPI(root_path=UVICORN_ROOT_PATH)
|
||||
app = FastAPI()
|
||||
|
||||
@app.get("/")
|
||||
def read_root():
|
||||
|
|
|
@ -7,6 +7,9 @@ User=__APP__
|
|||
Group=__APP__
|
||||
WorkingDirectory=__DATA_DIR__/
|
||||
|
||||
# UVICORN_ROOT_PATH is used by FastAPI to serve the 'docs' page correctly
|
||||
Environment="UVICORN_ROOT_PATH=__PATH__"
|
||||
|
||||
ExecStart=__INSTALL_DIR__/venv/bin/gunicorn --config __INSTALL_DIR__/gunicorn.conf.py FastAPIAppFolder:app --worker-class uvicorn.workers.UvicornWorker
|
||||
|
||||
StandardOutput=syslog
|
||||
|
|
|
@ -25,6 +25,11 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
|
|||
|
||||
ynh_change_url_nginx_config
|
||||
|
||||
ynh_script_progression --message="Updating systemd service..." --weight=1
|
||||
|
||||
ynh_add_systemd_config
|
||||
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
|
|
|
@ -47,7 +47,7 @@ ynh_add_config --template="gunicorn.conf.py" --destination="$install_dir/gunicor
|
|||
mkdir -p "$data_dir/FastAPIAppFolder"
|
||||
ynh_add_config --template="__init__.py" --destination="$data_dir/FastAPIAppFolder/__init__.py"
|
||||
ynh_app_setting_set --app=$app --key=main_folder --value="FastAPIAppFolder"
|
||||
ynh_app_setting_set --app=$app --key=requirements --value=0
|
||||
ynh_app_setting_set --app=$app --key=requirements_path --value=""
|
||||
|
||||
# Add the password to this user
|
||||
chpasswd <<< "${app}:${password}"
|
||||
|
|
Loading…
Reference in a new issue