Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nginx
GitHub Repository: nginx/nginx.org
Path: blob/main/tools/entrypoint.sh
1 views
1
#!/bin/sh
2
set -e
3
4
# Initial build
5
echo "Running initial build..."
6
make -C /var/www
7
8
TRIGGER="/tmp/rebuild_trigger"
9
10
# 1. File Watcher (Background)
11
# Monitors xml and xsls directories.
12
# Excludes generated files (dirindex.xml, varindex.xml) to prevent feedback loops.
13
echo "Starting file watcher..."
14
inotifywait -m -r \
15
-e close_write,moved_to,create \
16
--exclude '(dirindex|varindex)\.xml$' \
17
--format '%w%f' \
18
/var/www/xml /var/www/xsls \
19
| while read file; do
20
touch "$TRIGGER"
21
done &
22
23
# 2. Builder Loop (Background)
24
# Checks for the trigger file periodically.
25
(
26
while true; do
27
if [ -f "$TRIGGER" ]; then
28
# to debounce rapid-fire events (e.g. "Save All")
29
sleep 1.0
30
31
rm -f "$TRIGGER"
32
33
echo "Changes detected. Rebuilding..."
34
make -C /var/www || echo "Build failed. Fix the errors to trigger a rebuild."
35
else
36
# Polling interval
37
sleep 1.0
38
fi
39
done
40
) &
41
42
# 3. Nginx (Foreground)
43
echo "NOTICE: nginx.org development site is running at http://localhost:8001/"
44
exec nginx -g 'daemon off;'
45
46