34 lines
822 B
Python
34 lines
822 B
Python
"""
|
||
队列启动入口:读取 Config 并以 exec 方式启动 Dramatiq CLI。
|
||
开发与生产均使用该单一角色入口,由外层脚本/编排并行管理。
|
||
"""
|
||
|
||
import os
|
||
|
||
from jingrow.config import Config
|
||
from jingrow.utils.path import get_apps_path
|
||
|
||
|
||
def main() -> None:
|
||
processes = int(getattr(Config, "worker_processes", 1))
|
||
threads = int(getattr(Config, "worker_threads", 1))
|
||
|
||
args = [
|
||
"dramatiq",
|
||
"jingrow.services.queue",
|
||
"--processes",
|
||
str(processes),
|
||
"--threads",
|
||
str(threads),
|
||
]
|
||
# 仅从 Config.watch 控制是否启用 watch,目录固定为 apps 根目录
|
||
if bool(getattr(Config, "watch", False)):
|
||
args.extend(["--watch", str(get_apps_path())])
|
||
os.execvp("dramatiq", args)
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|
||
|
||
|