agnes-the-ai-analyst/services/data_refresh/systemd/data-refresh.service
Petr 2181d490e9 Fix systemd NAMESPACE failures caused by missing ReadWritePaths dirs
data-refresh.service: use /tmp instead of /tmp/data_analyst_staging in
ReadWritePaths — the subdirectory may not exist at service start, causing
mount namespace setup to fail before any Exec* directive runs.

deploy.sh: fix typo services/corporate-memory -> services/corporate_memory
so the mkdir conditional actually matches the repo directory name.

deploy.sh: add ReadWritePaths validation loop that auto-creates any missing
directories listed in installed .service files before daemon-reload. This
acts as a safety net against future NAMESPACE failures from new services.
2026-03-15 11:40:11 +01:00

33 lines
959 B
Desktop File

[Unit]
Description=Data Refresh - scheduled sync from BigQuery to local Parquet
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
User=root
Group=data-ops
WorkingDirectory=/opt/data-analyst/repo
ExecStart=/opt/data-analyst/.venv/bin/python3 -m src.data_sync --scheduled
# Environment
EnvironmentFile=/opt/data-analyst/.env
Environment=PYTHONPATH=/opt/data-analyst/repo
Environment=CONFIG_DIR=/opt/data-analyst/instance/config
# Write access to data directory, logs, and /tmp (for staging + lock file)
ProtectSystem=strict
ReadWritePaths=/data /opt/data-analyst/logs /tmp
PrivateTmp=false
# Sync can take a while for large tables
TimeoutStartSec=3600
# Prevent overlapping runs
ExecCondition=/usr/bin/test ! -f /tmp/data-refresh.lock
ExecStartPre=/usr/bin/touch /tmp/data-refresh.lock
ExecStartPost=/usr/bin/rm -f /tmp/data-refresh.lock
ExecStopPost=/usr/bin/rm -f /tmp/data-refresh.lock
[Install]
WantedBy=multi-user.target