diff --git a/conf/__init__.py b/conf/__init__.py index f75a4af..5703e85 100644 --- a/conf/__init__.py +++ b/conf/__init__.py @@ -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(): diff --git a/conf/systemd.service b/conf/systemd.service index 2c69049..84dd1bb 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -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 diff --git a/scripts/change_url b/scripts/change_url index ae914ad..0512850 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -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 #================================================= diff --git a/scripts/install b/scripts/install index ea4d260..2a58011 100755 --- a/scripts/install +++ b/scripts/install @@ -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}"