Skip to content

ucef-h/fastapi

Repository files navigation

fastapi-app

Simple FastAPI service exposing:

  • GET /api/v1/value
  • GET /healthz
  • GET /readyz

Run (local)

uvicorn app.main:app --host 0.0.0.0 --port 8080

Install systemd

Create a dedicated system account for the FastAPI service

sudo useradd --system --no-create-home --shell /usr/sbin/nologin fastapi

Create the application directory and assign ownership

sudo mkdir -p /opt/fastapi-service
sudo chown -R fastapi:fastapi /opt/fastapi-service

Install Python and Prerequisites

sudo yum update -y
sudo yum install -y python3 python3-venv git

Create virtual environment under the application directory

sudo python3 -m venv /opt/fastapi-service/.venv
sudo /opt/fastapi-service/.venv/bin/pip install --upgrade pip

Install the FastAPI service from GitHub or package repository

sudo /opt/fastapi-service/.venv/bin/pip install https://github.com/ucef-h/fastapi/releases/download/v1.0.5/fastapi_app-1.0.5-py3-none-any.whl

Copy the unit file to systemd’s directory

sudo cp /opt/fastapi-service/deploy/systemd/fastapi-app.service /etc/systemd/system/fastapi-app.service

Adjust permissions

sudo chmod 644 /etc/systemd/system/fastapi-app.service

Reload systemd to detect the new service

sudo systemctl daemon-reload

Enable automatic startup at boot

sudo systemctl enable fastapi-app

Start the service immediately

sudo systemctl start fastapi-app

Verify status (should show active)

sudo systemctl status fastapi-app --no-pager

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages