add chicken counting, mortality api for daily data sync. Also adjust karung sync to sync every 30 sec after publish cutoff time to update real data without clicking sync button manually
This commit is contained in:
1 parent
5ae477a99d
commit
6c21af745d
17 files changed
+791
-119
No files matched your search
@@ -39,3 +39,9 @@ IOT_API_BASE_URL=https://dashboard.cpsp.id/api/iot/flocks
|
||||
IOT_SYNC_LOOKBACK_MINUTES=20
|
||||
IOT_SYNC_MAX_PAGES=10
|
||||
IOT_FLOCK_ID_MAP={}
|
||||
|
||||
# Chicken counting edge vision API (counting + mortality; not gated by publish cutoff)
|
||||
CHICKEN_COUNTING_EDGE_BASE_URL=http://192.168.192.106:8090
|
||||
CHICKEN_COUNTING_EDGE_TIMEOUT_SECONDS=30
|
||||
CHICKEN_COUNTING_EDGE_COUNTING_SYNC_ENABLED=true
|
||||
CHICKEN_COUNTING_EDGE_MORTALITY_SYNC_ENABLED=true
|
||||
@@ -19,10 +19,10 @@ COPY backend/requirements.txt .
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
COPY backend/ .
|
||||
COPY docker/entrypoint-api.sh docker/entrypoint-cron.sh /app/
|
||||
COPY docker/entrypoint-api.sh docker/entrypoint-cron.sh docker/karung_sync_loop.sh /app/
|
||||
COPY docker/crontab /etc/cron.d/newdashboard
|
||||
|
||||
RUN chmod +x /app/entrypoint-api.sh /app/entrypoint-cron.sh \
|
||||
RUN chmod +x /app/entrypoint-api.sh /app/entrypoint-cron.sh /app/karung_sync_loop.sh \
|
||||
&& mkdir -p /app/data /app/media /app/staticfiles \
|
||||
&& chmod 0644 /etc/cron.d/newdashboard \
|
||||
&& crontab /etc/cron.d/newdashboard
|
||||
|
||||
+5
-1
@@ -4,5 +4,9 @@ PATH=/usr/local/bin:/usr/bin:/bin
|
||||
# IoT panel: real-time sync every 10 minutes (not gated by 17:00 publish cutoff).
|
||||
*/10 * * * * root cd /app && /usr/local/bin/python manage.py sync_iot_from_api >> /var/log/cron.log 2>&1
|
||||
|
||||
# Daily publish at 17:00 WIB — karung first (feed use counts until 16:59), then KPI rollups.
|
||||
# Chicken counting + mortality edge sync every 10 minutes (not gated by publish cutoff).
|
||||
*/10 * * * * root cd /app && /usr/local/bin/python manage.py sync_chicken_counting_from_edge >> /var/log/cron.log 2>&1
|
||||
|
||||
# Karung-web-admin: every 30s via karung_sync_loop.sh (started by entrypoint-cron.sh).
|
||||
# Daily publish — recompute KPI rollups from latest karung + counting.
|
||||
0 17 * * * root cd /app && /usr/local/bin/python manage.py sync_karung_from_web_admin >> /var/log/cron.log 2>&1 && /usr/local/bin/python manage.py recompute_kpi_rollups >> /var/log/cron.log 2>&1
|
||||
@@ -2,6 +2,8 @@
|
||||
set -e
|
||||
cd /app
|
||||
python manage.py migrate --noinput
|
||||
printenv | grep -E '^(PATH|DJANGO_|SECRET_|DB_|KARUNG_|IOT_|DASHBOARD_|DEBUG|ALLOWED_|BOOTSTRAP_|API_|CORS_|CSRF_|SESSION_)' \
|
||||
printenv | grep -E '^(PATH|DJANGO_|SECRET_|DB_|KARUNG_|IOT_|CHICKEN_COUNTING_|DASHBOARD_|DEBUG|ALLOWED_|BOOTSTRAP_|API_|CORS_|CSRF_|SESSION_)' \
|
||||
> /etc/environment || true
|
||||
# Cron min resolution is 1 minute; karung polls every 30s in a side loop.
|
||||
/app/karung_sync_loop.sh &
|
||||
exec cron -f
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
# Sub-minute karung sync — cron cannot schedule under 1 minute.
|
||||
set -eu
|
||||
cd /app
|
||||
while true; do
|
||||
/usr/local/bin/python manage.py sync_karung_from_web_admin >> /var/log/cron.log 2>&1 || true
|
||||
sleep 30
|
||||
done
|
||||
Reference in new issue
Block a user