59 lines
1.7 KiB
Desktop File
59 lines
1.7 KiB
Desktop File
[Unit]
|
|
Description=Frigate Object Batch Counter Service
|
|
Documentation=https://github.com/your-repo/frigate-counter
|
|
After=network-online.target mosquitto.service
|
|
Wants=network-online.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=frigate-counter
|
|
Group=frigate-counter
|
|
|
|
# Working directory where state file and DB live
|
|
WorkingDirectory=/opt/frigate-counter
|
|
|
|
# Path to your Python virtual environment
|
|
Environment="PYTHONPATH=/opt/frigate-counter"
|
|
Environment="PATH=/opt/frigate-counter/venv/bin:/usr/local/bin:/usr/bin:/bin"
|
|
Environment="CAMERA_NAME=cam_gudang_utara"
|
|
Environment="OBJECT_LABEL=ayam-potong"
|
|
Environment="FRIGATE_MQTT_HOST=192.168.1.10"
|
|
Environment="FRIGATE_MQTT_PORT=1883"
|
|
Environment="FRIGATE_MQTT_USER="
|
|
Environment="FRIGATE_MQTT_PASS="
|
|
Environment="FRIGATE_MQTT_TOPIC=frigate/events"
|
|
Environment="BATCH_TIMEOUT_SECONDS=60"
|
|
Environment="DAILY_CUTOFF_TIME=17:00"
|
|
Environment="DB_PATH=/opt/frigate-counter/frigate_counter.db"
|
|
Environment="STATE_FILE=/opt/frigate-counter/current_batch.json"
|
|
Environment="LOG_LEVEL=INFO"
|
|
|
|
# Or use an EnvironmentFile instead of inline variables:
|
|
# EnvironmentFile=/opt/frigate-counter/.env
|
|
|
|
ExecStart=/opt/frigate-counter/venv/bin/python /opt/frigate-counter/counter_service.py
|
|
ExecReload=/bin/kill -HUP $MAINPID
|
|
|
|
# Graceful shutdown: give the service time to persist the batch to DB
|
|
TimeoutStopSec=30
|
|
KillSignal=SIGTERM
|
|
|
|
# Restart policy
|
|
Restart=on-failure
|
|
RestartSec=5
|
|
StartLimitInterval=60s
|
|
StartLimitBurst=3
|
|
|
|
# Security hardening (optional but recommended)
|
|
NoNewPrivileges=true
|
|
ProtectSystem=strict
|
|
ProtectHome=true
|
|
ReadWritePaths=/opt/frigate-counter
|
|
PrivateTmp=true
|
|
ProtectKernelTunables=true
|
|
ProtectKernelModules=true
|
|
ProtectControlGroups=true
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|