Gå til innhold

Operations & Routines

Regular Tasks

Task Frequency Responsible
Check /health endpoint Daily Monitoring system
Verify sync worker ran OK Daily Manual / Task Scheduler
Review chat logs Weekly Administrator
Check disk space (cache + logs) Monthly Administrator

Start / Stop Chatbot API

Start:

cd C:\ftp\sites\clubsite-4\API
.\START_CHATBOT_v2.ps1

Stop: Find the process ID and terminate:

Get-Process -Name python | Where-Object { $_.CommandLine -like "*uvicorn*" } | Stop-Process

Check status:

Invoke-RestMethod http://127.0.0.1:8000/health

Manual Data Sync

Run the sync worker outside scheduled time:

cd C:\ftp\sites\clubsite-4\API\python
.\venv\Scripts\python.exe ..\chatbot\sync_worker.py

Verify cache files were updated:

Get-ChildItem C:\ftp\sites\clubsite-4\API\chatbot\cache\*.json |
  Select-Object Name, LastWriteTime, Length

Log Files

Chat interactions are logged to:

C:\ftp\sites\clubsite-4\API\chatbot\logs\{TENANT_ID}_chat.jsonl

View last 20 interactions:

Get-Content C:\ftp\sites\clubsite-4\API\chatbot\logs\SKI_chat.jsonl -Tail 20

Installation on a New Server

# 1. Copy codebase to C:\ftp\sites\clubsite-4\
# 2. Run installation script
cd C:\ftp\sites\clubsite-4\API
.\INSTALL_CHATBOT_2.ps1

# 3. Fill in .env
notepad C:\ftp\sites\clubsite-4\API\chatbot\.env

# 4. Run sync
cd python
.\venv\Scripts\python.exe ..\chatbot\sync_worker.py

# 5. Start API
cd ..
.\START_CHATBOT_v2.ps1

# 6. Verify
Invoke-RestMethod http://127.0.0.1:8000/health

Updating Python Dependencies

cd C:\ftp\sites\clubsite-4\API\python
.\venv\Scripts\Activate.ps1
pip install -r ..\chatbot\requirements.txt --upgrade

Adding a New Club (Tenant)

  1. Set boolChatbot = 1 in the Clubs table for the club
  2. Verify the clubFolder field (used as cache filename)
  3. Create an AI_Chatbot_Settings row for the club
  4. Run sync_worker.py manually
  5. Verify cache/{clubFolder}_context.json
  6. Update ALLOWED_TENANT_ID in API/python/app/app.py (temporary – removed in v2.1)
  7. Restart uvicorn
  8. Integrate ai_chatbot_loader.asp in the tenant folder

Log Rotation Routine

Logs are not rotated automatically. Recommended manual routine:

# Archive logs older than 90 days
$logDir = "C:\ftp\sites\clubsite-4\API\chatbot\logs"
$archiveDir = "C:\ftp\sites\clubsite-4\API\chatbot\logs\archive"
New-Item -ItemType Directory -Force $archiveDir
Get-ChildItem $logDir -Filter *.jsonl |
  Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-90) } |
  Move-Item -Destination $archiveDir