freeleaps-service-hub/apps/metrics/start_fastapi.sh
weicao 44f08eee68 Add metrics service with user registration API endpoints
- Add complete metrics microservice structure
- Implement StarRocks database integration
- Add user registration data query APIs:
  - Daily registered users by date range
  - Recent N days registration data
  - Registration data by start date and days
  - Registration summary statistics
- Add comprehensive error handling and logging
- Include test scripts and documentation
2025-09-11 17:35:20 +08:00

39 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
rp=$(dirname "$(realpath '$1')")
pushd $rp
APP_NAME=metrics
APP_PARENT_FOLDER=apps
GIT_REPO_ROOT=$(git rev-parse --show-toplevel)
CODEBASE_ROOT=$GIT_REPO_ROOT/$APP_PARENT_FOLDER/$APP_NAME
SITE_DEPLOY_FOLDER=$GIT_REPO_ROOT/sites/$APP_NAME/deploy
echo APP_NAME=$APP_NAME > .env
cat $SITE_DEPLOY_FOLDER/common/.env >> .env
echo GIT_REPO_ROOT=$(git rev-parse --show-toplevel) >> .env
echo CODEBASE_ROOT=$GIT_REPO_ROOT/$APP_PARENT_FOLDER/$APP_NAME >> .env
echo SITE_DEPLOY_FOLDER=$GIT_REPO_ROOT/sites/$APP_NAME/deploy >> .env
cat $SITE_DEPLOY_FOLDER/common/.host.env >> .env
cat $SITE_DEPLOY_FOLDER/local/.env >> .env
. .env
if [ -d "$VENV_DIR" ]
then
echo "Folder $VENV_DIR exists. Proceed to next steps"
else
echo "Folder $VENV_DIR doesn't exist. create it"
sudo apt install python3-pip
python3 -m pip install virtualenv
python3 -m virtualenv $VENV_DIR
fi
source $VENV_DIR/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
uvicorn webapi.main:app --reload --host 0.0.0.0 --port $SERVICE_API_ACCESS_PORT
popd