[Unit]
Description=QFQ Email Sync Service
After=network.target

[Service]
Type=simple
# Run as the webserver user: OAuth2 token files are created/refreshed by the web UI (mode 0600,
# owned by the webserver user) and the daemon must read/write the same files. Adjust if your
# webserver runs as a different user (e.g. apache, nginx, _www).
User=www-data
Group=www-data
Environment="SERVICE_FILE_PATH=/etc/systemd/system/emailSync.service"
# Deploy emailSync.sh from Resources/Public/script/ to this path (or adjust) and set the
# instance path(s) inside it (SCRIPTS=...).
ExecStart=/etc/scripts/emailSync.sh
# The watchdog handles restarts of the individual email-sync.php daemons itself; do not let
# systemd restart the watchdog on its own controlled exit.
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
