Files
UAV-CO2/CONFIG_README.md

165 lines
3.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# GasFlux INI Configuration Guide
GasFlux 现在支持使用 INI 配置文件来管理路径和网络设置,提供更灵活的部署选项。
## 配置文件位置
GasFlux 会按以下顺序查找配置文件:
1. `gasflux.ini` (当前目录)
2. `config.ini` (当前目录)
3. `gasflux.ini` (项目根目录)
如果找不到配置文件,将使用默认值和环境变量。
## 配置示例
复制 `gasflux.ini.example``gasflux.ini` 并根据需要修改:
```ini
[server]
# 服务器配置
host = 0.0.0.0
port = 5000
debug = false
base_url = http://localhost:5000
[paths]
# 目录路径配置(相对于项目根目录或绝对路径)
uploads = ./web_api_data/uploads
outputs = ./web_api_data/outputs
[limits]
# 文件大小限制
max_content_length = 104857600 # 100MB
[logging]
# 日志配置
level = INFO
file = logs/gasflux_api.log
[security]
# 安全设置
admin_bootstrap_key = your_secret_key_here
[cleanup]
# 任务清理设置
task_cleanup_interval = 3600 # 1小时
max_task_age = 86400 # 24小时
janitor_dry_run = false
[performance]
# 性能调优
threads = 8
connection_limit = 100
channel_timeout = 300
[database]
# 数据库配置
path =
[api_keys]
# API密钥持久化设置
persist_backend = sqlite
```
## 配置说明
### [server] 服务器配置
- `host`: 服务器监听地址 (默认: 0.0.0.0)
- `port`: 服务器监听端口 (默认: 5000)
- `debug`: 调试模式 (默认: false)
- `base_url`: 对外访问的基础URL (默认: http://localhost:5000)
### [paths] 路径配置
- `uploads`: 上传文件存储目录 (默认: ./web_api_data/uploads)
- `outputs`: 计算结果输出目录 (默认: ./web_api_data/outputs)
路径可以是:
- 相对路径(相对于项目根目录)
- 绝对路径
- 支持 `~` 展开用户主目录
### [limits] 限制配置
- `max_content_length`: 最大文件上传大小,字节 (默认: 104857600 = 100MB)
### [logging] 日志配置
- `level`: 日志级别 (DEBUG, INFO, WARNING, ERROR, CRITICAL)
- `file`: 日志文件路径 (默认: logs/gasflux_api.log)
### [security] 安全配置
- `admin_bootstrap_key`: 管理员引导密钥用于初始创建API密钥
### [cleanup] 清理配置
- `task_cleanup_interval`: 任务清理检查间隔,秒 (默认: 3600)
- `max_task_age`: 任务最大保留时间,秒 (默认: 86400)
- `janitor_dry_run`: 清理程序干运行模式,只记录不实际删除 (默认: false)
### [performance] 性能配置
- `threads`: 服务器线程数 (默认: 8)
- `connection_limit`: 连接限制 (默认: 100)
- `channel_timeout`: 通道超时,秒 (默认: 300)
### [database] 数据库配置
- `path`: SQLite数据库文件路径为空则使用默认位置
### [api_keys] API密钥配置
- `persist_backend`: 任务持久化后端 (json/sqlite/both默认: sqlite)
## 环境变量兼容性
所有配置项都可以通过环境变量覆盖,格式为 `GASFLUX_{SECTION}_{KEY}`,例如:
- `GASFLUX_SERVER_HOST=127.0.0.1`
- `GASFLUX_PATHS_UPLOADS=/custom/uploads`
环境变量优先级高于 INI 文件配置。
## 路径处理逻辑
1. **全局目录**: `uploads``outputs` 目录由 INI 配置决定
2. **任务子目录**: 每个任务在这些目录下创建 `{task_id}` 子目录
3. **YAML 配置**: 上传的 YAML 配置文件中的 `output_dir` 仍然可以覆盖全局设置
## 启动验证
启动时会显示配置信息:
```
Configuration loaded from: /path/to/gasflux.ini
Directories initialized - Upload: /path/to/uploads, Output: /path/to/outputs
```
## 示例配置
### 开发环境
```ini
[server]
host = 127.0.0.1
port = 5000
debug = true
[paths]
uploads = ./dev_uploads
outputs = ./dev_outputs
[logging]
level = DEBUG
```
### 生产环境
```ini
[server]
host = 0.0.0.0
port = 80
debug = false
base_url = https://api.example.com
[paths]
uploads = /data/gasflux/uploads
outputs = /data/gasflux/outputs
[logging]
level = INFO
file = /var/log/gasflux/api.log
[security]
admin_bootstrap_key = your_production_bootstrap_key
```