Skip to content

Commit 976e56b

Browse files
CWA can now autodetect if it's deployed via Docker for Windows or Docker for Mac and will adjust the monitoring scripts to use polling instead of inotify accordingly.
[bug] Ingest Not Triggering Automatically when hosted on Docker for Windows or Docker for Maxc Fixes #402
1 parent 5cdb27b commit 976e56b

File tree

4 files changed

+55
-3
lines changed

4 files changed

+55
-3
lines changed

CONTRIBUTORS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CONTRIBUTORS
22

33
This file is automatically generated. DO NOT EDIT MANUALLY.
4-
Generated on: 2025-08-19T15:15:09.492072Z
4+
Generated on: 2025-08-19T15:26:49.024475Z
55

66
Upstream project: https://github.com/janeczku/calibre-web
77
Fork project (Calibre-Web Automated, since 2024): https://github.com/crocodilestick/calibre-web-automated
@@ -289,7 +289,7 @@ Copyright (C) 2024-2025 Calibre-Web Automated contributors
289289
- zhiyue (1 commits)
290290
# Fork Contributors (crocodilestick/calibre-web-automated)
291291

292-
- crocodilestick (515 commits)
292+
- crocodilestick (518 commits)
293293
- jmarmstrong1207 (73 commits)
294294
- demitrix (30 commits)
295295
- sirwolfgang (22 commits)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ This tells CWA to avoid enabling WAL on the Calibre `metadata.db` and the `app.d
9393

9494
#### File watching on network shares
9595

96-
- By default, CWA uses Linux inotify (via `inotifywait`) to detect new files in the ingest folder with minimal latency and overhead.
96+
- By default, CWA uses Linux `inotify` (via `inotifywait`) to detect new files in the ingest folder with minimal latency and overhead.
9797
- On network shares (NFS/SMB), filesystem events can be unreliable or unavailable. When `NETWORK_SHARE_MODE=true` is set, CWA switches the ingest and metadata watcher services to a polling-based watcher that periodically scans for changes. This improves reliability on NAS/network mounts at the cost of slightly higher I/O and up to a few seconds of latency.
98+
- On Docker Desktop (Windows/macOS), the container runs on a LinuxKit/WSL2 VM and host-mounted paths may not propagate `inotify` events reliably. CWA auto-detects Docker Desktop at startup and prefers the same polling watcher for reliability.
9899
- Advanced: You can also force polling regardless of share mode by setting `CWA_WATCH_MODE=poll`.
99100

100101
## **_Features:_**

root/etc/s6-overlay/s6-rc.d/cwa-ingest-service/run

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,26 @@ run_fallback() {
2222
done
2323
}
2424

25+
# Detect if running under Docker Desktop (Windows/macOS) and prefer polling
26+
is_docker_desktop() {
27+
local osr mounts
28+
osr=$(cat /proc/sys/kernel/osrelease 2>/dev/null || true)
29+
# WSL2 / Windows kernel markers
30+
if echo "$osr" | grep -qi 'microsoft'; then
31+
return 0
32+
fi
33+
# LinuxKit kernel used by Docker Desktop VM
34+
if echo "$osr" | grep -qi 'linuxkit'; then
35+
return 0
36+
fi
37+
# Mount hints for Desktop host path mappings
38+
mounts=$(cat /proc/self/mountinfo 2>/dev/null || true)
39+
if echo "$mounts" | grep -Eqi '/host_mnt/|/Users/|osxfs|virtiofs.*docker'; then
40+
return 0
41+
fi
42+
return 1
43+
}
44+
2545
# Prefer polling when running over network shares to better handle NFS/SMB semantics
2646
if [ "${NETWORK_SHARE_MODE,,}" = "true" ] || [ "${NETWORK_SHARE_MODE}" = "1" ] || [ "${NETWORK_SHARE_MODE,,}" = "yes" ] || [ "${NETWORK_SHARE_MODE,,}" = "on" ]; then
2747
echo "[cwa-ingest-service] NETWORK_SHARE_MODE=true detected; using polling watcher instead of inotify"
@@ -35,6 +55,13 @@ if [ "${CWA_WATCH_MODE:-inotify}" = "poll" ]; then
3555
exit 0
3656
fi
3757

58+
# Prefer polling on Docker Desktop (Windows/macOS) for reliable detection on host-mounted paths
59+
if is_docker_desktop; then
60+
echo "[cwa-ingest-service] Docker Desktop environment detected; using polling watcher instead of inotify"
61+
run_fallback
62+
exit 0
63+
fi
64+
3865
# Monitor the folder for new files using inotify; on error, switch to fallback.
3966
(
4067
set -o pipefail

root/etc/s6-overlay/s6-rc.d/metadata-change-detector/run

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,23 @@ run_fallback() {
2323
done
2424
}
2525

26+
# Detect if running under Docker Desktop (Windows/macOS) and prefer polling
27+
is_docker_desktop() {
28+
local osr mounts
29+
osr=$(cat /proc/sys/kernel/osrelease 2>/dev/null || true)
30+
if echo "$osr" | grep -qi 'microsoft'; then
31+
return 0
32+
fi
33+
if echo "$osr" | grep -qi 'linuxkit'; then
34+
return 0
35+
fi
36+
mounts=$(cat /proc/self/mountinfo 2>/dev/null || true)
37+
if echo "$mounts" | grep -Eqi '/host_mnt/|/Users/|osxfs|virtiofs.*docker'; then
38+
return 0
39+
fi
40+
return 1
41+
}
42+
2643
# Prefer polling when running over network shares to better handle NFS/SMB semantics
2744
if [ "${NETWORK_SHARE_MODE,,}" = "true" ] || [ "${NETWORK_SHARE_MODE}" = "1" ] || [ "${NETWORK_SHARE_MODE,,}" = "yes" ] || [ "${NETWORK_SHARE_MODE,,}" = "on" ]; then
2845
echo "[metadata-change-detector] NETWORK_SHARE_MODE=true detected; using polling watcher instead of inotify"
@@ -36,6 +53,13 @@ if [ "${CWA_WATCH_MODE:-inotify}" = "poll" ]; then
3653
exit 0
3754
fi
3855

56+
# Prefer polling on Docker Desktop (Windows/macOS) for reliable detection on host-mounted paths
57+
if is_docker_desktop; then
58+
echo "[metadata-change-detector] Docker Desktop environment detected; using polling watcher instead of inotify"
59+
run_fallback
60+
exit 0
61+
fi
62+
3963
(
4064
set -o pipefail
4165
s6-setuidgid abc inotifywait -m -e close_write -e moved_to --exclude '^.*\.(swp)$' "$WATCH_FOLDER" |

0 commit comments

Comments
 (0)