Skip to content

Commit 4f7d529

Browse files
authored
new tool for running the docs server (#117)
1 parent ce7fa89 commit 4f7d529

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

start_docs_server.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
# convient script to run the docs server. It automatically rebuilds and restarts when you change code. You just need to refresh your browser.
3+
cd "$(dirname "$0")"
4+
WATCH_PATH="."
5+
START_SERVER_CMD="make develop-docs-comprehensive"
6+
while true; do
7+
$START_SERVER_CMD &
8+
9+
echo "Server started"
10+
11+
echo "Waiting for 15 seconds before starting to watch for file changes..."
12+
sleep 15
13+
14+
if [[ "$OSTYPE" == "darwin"* ]]; then
15+
CHANGED_FILE=$(fswatch -1 --exclude 'docs/static/api-reference-docs' --exclude 'build/' --exclude '/docs/.docusaurus' --exclude 'changes.log' --exclude 'docs/node_modules/.cache/webpack' --exclude '.git/' $WATCH_PATH)
16+
echo "Detected changes in: $CHANGED_FILE"
17+
else
18+
echo "OS not supported"
19+
exit 1
20+
fi
21+
22+
echo "Code changed. Attempting to kill server on port 3000..."
23+
24+
# Send SIGTERM to the process listening on port 3000
25+
lsof -ti:3000 | xargs kill
26+
27+
# Wait for a bit to give the process a chance to shut down gracefully
28+
sleep 5
29+
30+
# Check if any process is still listening on port 3000
31+
if lsof -ti:3000 > /dev/null; then
32+
echo "Process didn't shut down gracefully. Force killing..."
33+
lsof -ti:3000 | xargs kill -9
34+
sleep 2
35+
36+
# Final check
37+
if lsof -ti:3000 > /dev/null; then
38+
echo "ERROR: Unable to kill the process running on port 3000. Exiting..."
39+
exit 1
40+
fi
41+
fi
42+
43+
44+
# Additional sleep to ensure port is released before restarting the server.
45+
echo "Waiting for an additional 5 seconds before restarting server..."
46+
sleep 5
47+
48+
done

0 commit comments

Comments
 (0)