Files
autoclip/backend/desktop_celery.py
Kris K 593cc62bd5 fix: desktop client, CI fixes, and backend (#61)
Squashed merge of fix/problem-fixes-from-main.

- Desktop client (Tauri v2) wiring + packaging
- CI workflow updates (Python 3.11, Rust toolchain, Tauri CLI, WebKit deps)
- Backend test fix (test_missing_api_key respects CI-injected env var)
- build_backend.py: support CI without venv + Windows-safe ASCII output

Desktop build workflows (Linux/Windows/macOS) still failing — tracked in #65.
2026-05-28 15:48:49 +08:00

39 lines
1.2 KiB
Python
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.
"""
桌面模式Celery配置
使用SQLite作为Broker和Backend适合单机桌面应用
"""
import os
if os.getenv("AUTOCLIP_DESKTOP_MODE", "").lower() not in {"1", "true", "yes"}:
raise RuntimeError("此模块仅在桌面模式下可用")
from celery import Celery
from pathlib import Path
# 文件系统 broker + sqlite backend示例
app_dir = Path(os.getenv("AUTOCLIP_APP_DIR", "~/Library/Application Support/AutoClip")).expanduser()
app_dir.mkdir(parents=True, exist_ok=True)
# 创建Celery目录
celery_dir = app_dir / "celery"
celery_dir.mkdir(parents=True, exist_ok=True)
(celery_dir / "in").mkdir(exist_ok=True)
(celery_dir / "out").mkdir(exist_ok=True)
(celery_dir / "processed").mkdir(exist_ok=True)
celery_app = Celery(
"autoclip_desktop",
broker="filesystem://",
backend=f"db+sqlite:///{app_dir}/celery/results.sqlite3",
)
celery_app.conf.update(
broker_transport_options={"data_folder_in": str(app_dir / "celery" / "in"),
"data_folder_out": str(app_dir / "celery" / "out"),
"data_folder_processed": str(app_dir / "celery" / "processed")},
task_ignore_result=False,
)
if __name__ == '__main__':
celery_app.start()