dramatiq增加watch支持热重载,默认监控apps目录

This commit is contained in:
jingrow 2025-10-30 23:16:50 +08:00
parent 8b25b8ccec
commit 6c344f776f
4 changed files with 9 additions and 1 deletions

View File

@ -46,6 +46,7 @@ class Settings(BaseSettings):
# 异步任务队列Dramatiq配置
worker_processes: int = 1
worker_threads: int = 1
watch: bool = True
class Config:
env_file = str(Path(__file__).resolve().parents[3] / '.env')

View File

@ -20,6 +20,11 @@ def main() -> None:
"--threads",
str(threads),
]
# 仅从 Config.watch 控制是否启用 watch目录固定为 apps 根目录
if bool(getattr(Config, "watch", False)):
current_dir = os.path.dirname(__file__)
apps_dir = os.path.abspath(os.path.join(current_dir, "..", ".."))
args.extend(["--watch", apps_dir])
os.execvp("dramatiq", args)

View File

@ -9,4 +9,6 @@ dependencies = [
"pydantic-settings>=2.0.0",
"qdrant-client==1.15.1",
"requests==2.31.0",
"dramatiq",
"dramatiq[watch]",
]

View File

@ -1,7 +1,7 @@
{
"name": "jingrow",
"version": "1.0.0",
"description": "AI Agent工作流平台",
"description": "AI Agent Framework",
"scripts": {
"dev": "./dev.sh start",
"stop": "./dev.sh stop",