A universal CLI launcher for FastAPI applications with daemon mode, logging, and rich UI
Project description
FastAPI Launcher ๐
A universal CLI launcher for FastAPI applications with daemon mode, logging, and rich UI.
ไธไธช้็จ็ FastAPI ๆๅกๅฏๅจๅจ๏ผๆฏๆๅฎๆค่ฟ็จๆจกๅผใๆฅๅฟ็ฎก็ๅ็พๅ็ป็ซฏ่พๅบใ
Features | ็นๆง
- ๐ฅ Hot Reload - Development mode with auto-reload | ๅผๅๆจกๅผ่ชๅจ้่ฝฝ
- ๐ Production Ready - Multi-worker support with uvicorn/gunicorn | ็ไบงๆจกๅผๅค worker ๆฏๆ
- ๐ป Daemon Mode - Background process support (Unix) | ๅฎๆค่ฟ็จๆจกๅผ
- ๐ Rich UI - Beautiful terminal output with Rich | ็พๅ็ป็ซฏ่พๅบ
- โ๏ธ Flexible Config - CLI, ENV, .env, pyproject.toml | ็ตๆดป็้ ็ฝฎ็ณป็ป
- ๐ Multi-Environment - staging/qa/prod custom environments | ๅค็ฏๅข้ ็ฝฎๆฏๆ
- ๐ฅ Health Check - Built-in health monitoring | ๅ ็ฝฎๅฅๅบทๆฃๆฅ
- ๐ Access Logs - Request logging with slow request detection | ่ฏทๆฑๆฅๅฟๅๆ ข่ฏทๆฑๆฃๆต
- ๐ Auto Discovery - Automatically find your FastAPI app | ่ชๅจๅ็ฐ App
- ๐ฏ Smart Mode - Auto-detect dev/prod based on environment | ๆบ่ฝๆจกๅผๆฃๆต
- ๐ก Real-time Monitor - TUI monitor for server status | ๅฎๆถ TUI ็ๆง
- ๐ฆ Gunicorn Backend - Optional Gunicorn for enhanced process management | ๅฏ้ Gunicorn ๅ็ซฏ
Installation | ๅฎ่ฃ
# Using pip
pip install fastapi-launcher
# With optional Gunicorn support
pip install fastapi-launcher[gunicorn]
# With TUI monitor
pip install fastapi-launcher[monitor]
# All extras
pip install fastapi-launcher[all]
# Using uv
uv add fastapi-launcher
Quick Start | ๅฟซ้ๅผๅง
# Initialize config in pyproject.toml
fa init
# Smart mode - auto-detect dev/prod
fa run
# Development mode with hot reload
fa dev
# Production mode
fa start --workers 4
# Start with specific environment
fa start --env staging
# Gunicorn backend (Unix only)
fa start --server gunicorn --workers 8
# Daemon mode (Unix only)
fa start --daemon
# Check status (detailed worker info)
fa status --verbose
# Stop server
fa stop
# Trigger hot reload
fa reload
# Real-time monitor
fa monitor
# View logs
fa logs --follow
# Health check
fa health
# Show configuration
fa config
# Check dependencies
fa check
Configuration | ้ ็ฝฎ
Configuration Priority | ้ ็ฝฎไผๅ ็บง
- CLI arguments (highest) | CLI ๅๆฐ๏ผๆ้ซ๏ผ
- Environment variables (
FA_prefix) | ็ฏๅขๅ้ .envfile | .env ๆไปถpyproject.toml [tool.fastapi-launcher.envs.<name>](if --env specified) | ๅฝๅ็ฏๅข้ ็ฝฎpyproject.toml [tool.fastapi-launcher]| ๅบ็ก้ ็ฝฎ- Default values (lowest) | ้ป่ฎคๅผ๏ผๆไฝ๏ผ
pyproject.toml
[tool.fastapi-launcher]
app = "main:app"
host = "127.0.0.1"
port = 8000
log_level = "info"
# Development mode overrides
[tool.fastapi-launcher.dev]
reload = true
log_level = "debug"
# Production mode overrides
[tool.fastapi-launcher.prod]
workers = 4
log_format = "json"
daemon = false
# Named environments (use with --env)
[tool.fastapi-launcher.envs.staging]
host = "0.0.0.0"
workers = 2
log_level = "info"
[tool.fastapi-launcher.envs.qa]
host = "0.0.0.0"
workers = 1
log_level = "debug"
[tool.fastapi-launcher.envs.prod]
host = "0.0.0.0"
workers = 8
server = "gunicorn"
max_requests = 1000
timeout_graceful_shutdown = 30
log_level = "warning"
Environment Variables | ็ฏๅขๅ้
# Environment selection
FA_ENV=staging
# Server configuration
FA_APP=main:app
FA_HOST=0.0.0.0
FA_PORT=8000
FA_RELOAD=true
FA_WORKERS=4
# Server backend (uvicorn/gunicorn)
FA_SERVER=uvicorn
# Graceful shutdown
FA_TIMEOUT_GRACEFUL_SHUTDOWN=10
# Gunicorn-specific (when FA_SERVER=gunicorn)
FA_MAX_REQUESTS=1000
FA_MAX_REQUESTS_JITTER=100
# Logging
FA_LOG_LEVEL=info
FA_LOG_FORMAT=pretty # or json
FA_DAEMON=false
Commands | ๅฝไปค
fa init
Initialize FastAPI Launcher configuration.
fa init # Add config to pyproject.toml
fa init --env # Also generate .env.example
fa init --force # Overwrite existing config
fa run
Smart start - auto-detect dev/prod mode based on environment.
fa run # Detect environment and start
# Detection priority:
# 1. FA_ENV environment variable
# 2. PYTHON_ENV environment variable
# 3. NODE_ENV environment variable
# 4. .env file
# 5. Heuristics (Dockerfile โ prod, .git/hooks/pre-commit โ dev)
fa dev
Start development server with hot reload.
fa dev # Auto-discover app
fa dev --app main:app # Specify app
fa dev --port 9000 # Custom port
fa dev --no-reload # Disable reload
fa dev --reload-dirs src,lib # Watch specific dirs
fa dev --env staging # Use staging environment
fa start
Start production server.
fa start # Default 4 workers
fa start --workers 8 # 8 workers
fa start --daemon # Background mode
fa start --host 0.0.0.0 # Bind to all interfaces
fa start --env staging # Use staging environment
fa start --server gunicorn # Use Gunicorn backend
fa start --max-requests 1000 # Worker restart after N requests
fa start --timeout-graceful-shutdown 30 # Graceful shutdown timeout
fa stop
Stop running server.
fa stop # Graceful shutdown
fa stop --force # Force kill
fa stop --timeout 30 # Custom timeout
fa restart
Restart server.
fa restart # Stop + Start
fa restart --timeout 10 # Custom stop timeout
fa reload
Trigger hot reload on running server (Unix only).
fa reload # Send SIGHUP to server
fa status
Show server status.
fa status # Basic status
fa status --verbose # Include worker details
# Output:
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# โ Server Status โ
# โโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโค
# โ Status โ โ Running โ
# โ PID โ 12345 โ
# โ URL โ http://...:8000 โ
# โ Uptime โ 2h 30m 15s โ
# โ Memory โ 128.5 MB โ
# โ Workers โ 4 โ
# โโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโ
fa monitor
Real-time monitoring with TUI interface.
fa monitor # TUI mode (requires textual)
fa monitor --no-tui # Simple CLI refresh mode
fa monitor --refresh 0.5 # Custom refresh interval
fa logs
View server logs.
fa logs # Last 100 lines
fa logs -n 50 # Last 50 lines
fa logs --follow # Tail mode
fa logs --type access # Access logs
fa logs --type error # Error logs
fa health
Check server health.
fa health # Default endpoint
fa health --path /ready # Custom endpoint
fa health --timeout 10 # Custom timeout
fa config
Show current configuration.
fa config
# Output shows merged config from all sources
fa check
Check dependencies and configuration.
fa check
# โ FastAPI is installed
# โ uvicorn is installed
# โ Configuration is valid
# โ App path is valid: main:app
fa clean
Clean runtime files.
fa clean # Interactive
fa clean --yes # Skip confirmation
fa clean --logs # Only log files
Project Structure | ้กน็ฎ็ปๆ
After running fa start, a runtime directory is created:
your-project/
โโโ pyproject.toml
โโโ main.py
โโโ runtime/
โโโ fa.pid # PID file
โโโ logs/
โโโ fa.log # Application log
โโโ access.log # Request log
โโโ error.log # Error log
App Auto-Discovery | ่ชๅจๅ็ฐ
FastAPI Launcher will look for your app in these locations:
main.pyโmain:appapp.pyโapp:appapi.pyโapi:appserver.pyโserver:appsrc/main.pyโsrc.main:app
Supported variable names: app, application, api
License | ่ฎธๅฏ่ฏ
MIT License
Contributing | ่ดก็ฎ
Contributions are welcome! Please feel free to submit issues and pull requests.
ๆฌข่ฟ่ดก็ฎ๏ผ่ฏท้ๆถๆไบค issues ๅ pull requestsใ
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_launcher-0.2.2.tar.gz.
File metadata
- Download URL: fastapi_launcher-0.2.2.tar.gz
- Upload date:
- Size: 36.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6484d706fd5b793af5282f156ad86db05fada9f94168f670845b80694bf0fb2c
|
|
| MD5 |
f4f4bc0318f695b0bdeedea046df83d1
|
|
| BLAKE2b-256 |
e44b9b5c4ca864996c17ba4bcb5632a6a5ad4abb48278f5cc9ee18cee0e97abe
|
File details
Details for the file fastapi_launcher-0.2.2-py3-none-any.whl.
File metadata
- Download URL: fastapi_launcher-0.2.2-py3-none-any.whl
- Upload date:
- Size: 45.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27b2142953de49769c84bd96e3299dc719d66c1d9d42851a5231adde0b2daf82
|
|
| MD5 |
0ee7a092688286eff36dc1764a096351
|
|
| BLAKE2b-256 |
5fe7eb73b942d0d867df6d1a790f0058b6b7a83aa9022d2312c139e1e15540a4
|