fix sack reload feature to use the same as chicken counting ,etc

This commit is contained in:
Alberto-Audrix committed 2026-11-02 13:45:35 +07:00
1 parent 85cdc234c3
commit 9d4c4ff23b
6 files changed
+10 -13

No files matched your search

+1
View File
@@ -77,6 +77,7 @@ const Dashboard: React.FC<Props> = ({ setView }) => {
await Promise.all([
api.countings.sync({ cycle_id: cycleId }).catch(() => null),
api.weights.sync({ cycle_id: cycleId }).catch(() => null),
api.karungs.request?.({ cycle_id: cycleId, section: 'today' })?.catch(() => null),
]);
const [kpiRows, countingRows, manualRows, weightRows, karungRows, freshCycle] =
await Promise.all([
+6
View File
@@ -31,6 +31,12 @@ const FeedSackCountingPage: React.FC<{ onSettings: () => void }> = ({ onSettings
}
setError(null);
try {
try {
await api.karungs.request({ cycle_id: cycleId, section: 'today' });
} catch {
// Best-effort karung-web-admin sync: don't fail page load if upstream service is temporarily unreachable
}
const [karungRows, manualList, freshCycle] = await Promise.all([
api.karungs.list({ cycle_id: cycleId }),
api.manualInputs.list({ cycle_id: cycleId }),
+2 -2
View File
@@ -19,11 +19,11 @@ COPY backend/requirements.txt .
RUN pip install -r requirements.txt
COPY backend/ .
COPY docker/entrypoint-api.sh docker/entrypoint-cron.sh docker/karung_sync_loop.sh docker/edge_sync_loop.sh /app/
COPY docker/entrypoint-api.sh docker/entrypoint-cron.sh docker/edge_sync_loop.sh /app/
COPY docker/crontab /etc/cron.d/newdashboard
RUN sed -i 's/\r$//' /app/*.sh \
&& chmod +x /app/entrypoint-api.sh /app/entrypoint-cron.sh /app/karung_sync_loop.sh /app/edge_sync_loop.sh \
&& chmod +x /app/entrypoint-api.sh /app/entrypoint-cron.sh /app/edge_sync_loop.sh \
&& mkdir -p /app/data /app/media /app/staticfiles \
&& chmod 0644 /etc/cron.d/newdashboard \
&& crontab /etc/cron.d/newdashboard
+1 -1
View File
@@ -4,6 +4,6 @@ PATH=/usr/local/bin:/usr/bin:/bin
# NOTE: docker/entrypoint-cron.sh regenerates this file from DASHBOARD_PUBLISH_HOUR/MINUTE
# at container start. Keep this checked-in copy as documentation / fallback defaults (17:00).
# Karung-web-admin & Edge Chicken Counting: every 30s via sync loops (started by entrypoint-cron.sh).
# Edge Chicken Counting: every 30s via sync loop (started by entrypoint-cron.sh).
# Daily publish — recompute KPI rollups (hour/minute come from DASHBOARD_PUBLISH_* at runtime).
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
View File
@@ -13,7 +13,6 @@ CRON_FILE=/etc/cron.d/newdashboard
echo "SHELL=/bin/sh"
echo "PATH=/usr/local/bin:/usr/bin:/bin"
echo ""
echo "# Karung-web-admin: every 30s via karung_sync_loop.sh (started below)."
echo "# Chicken counting + weight edge: every 30s via edge_sync_loop.sh (started below)."
echo "# Daily publish — karung sync then KPI rollups at configured cutoff."
echo "${PUBLISH_MINUTE} ${PUBLISH_HOUR} * * * 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"
@@ -21,6 +20,5 @@ CRON_FILE=/etc/cron.d/newdashboard
chmod 0644 "$CRON_FILE"
crontab "$CRON_FILE"
/app/karung_sync_loop.sh &
/app/edge_sync_loop.sh &
exec cron -f
-8
View File
@@ -1,8 +0,0 @@
#!/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