Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new tool for running the docs server #117

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions start_docs_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
# convient script to run the docs server. It automatically rebuilds and restarts when you change code. You just need to refresh your browser.
WATCH_PATH="."
sunildkumar marked this conversation as resolved.
Show resolved Hide resolved
START_SERVER_CMD="make develop-docs-comprehensive"

while true; do
$START_SERVER_CMD &
SERVER_PID=$!
sunildkumar marked this conversation as resolved.
Show resolved Hide resolved

echo "Server started with PID: $SERVER_PID"

echo "Waiting for 15 seconds before starting to watch for file changes..."
sleep 15

if [[ "$OSTYPE" == "darwin"* ]]; then
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 | tee -a changes.log
else
echo "OS not supported"
exit 1
fi

echo "Code changed. Attempting to kill server with PID: $SERVER_PID..."
sunildkumar marked this conversation as resolved.
Show resolved Hide resolved

# Attempt to kill the npm process directly.
pkill -f "npm"
sleep 2

if pgrep -f "npm" > /dev/null; then
echo "WARNING: npm process is still running!"
# If npm process is still running, try killing it harder
pkill -9 -f "npm"
sleep 2
if pgrep -f "npm" > /dev/null; then
echo "ERROR: Unable to kill the npm process. Exiting..."
exit 1
fi
fi

# Additional sleep to ensure port is released before restarting the server.
echo "Waiting for an additional 5 seconds before restarting server..."
sleep 5

# Clear the log file to avoid reading old changes
> changes.log
sunildkumar marked this conversation as resolved.
Show resolved Hide resolved

done
Loading