Skip to content

Commit

Permalink
Pgrep improvements (#3590)
Browse files Browse the repository at this point in the history
  • Loading branch information
tunetheweb committed Feb 26, 2024
1 parent c30bec6 commit 90cca5b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/tools/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ function check_continue {
fi
}

if [ ! "$(which pgrep)" ]; then
echo "Need pgrep installed. Try 'brew install proctools'"
exit 1
fi

echo "Beginning the Web Almanac deployment process"

# This script must be run from src directory
Expand Down Expand Up @@ -95,7 +100,7 @@ git status
git pull
git pull origin main

if [ "$(pgrep -f 'python main.py')" ]; then
if [ "$(pgrep -if 'python main.py')" ]; then
echo "Killing existing server to run a fresh version"
pkill -9 python main.py
fi
Expand Down Expand Up @@ -192,7 +197,7 @@ git status
echo "Checking out main branch"
git checkout main

if [ "$(pgrep -f 'python main.py')" ]; then
if [ "$(pgrep -if 'python main.py')" ]; then
echo "Killing server so backgrounded version isn't left there"
pkill -9 -f "python main.py"
fi
Expand Down
13 changes: 9 additions & 4 deletions src/tools/scripts/run_and_test_website.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@ if [ -d "src" ]; then
cd src
fi

if [ "$(pgrep -f 'python main.py')" ]; then
if [ ! "$(which pgrep)" ]; then
echo "Need pgrep installed. Try 'brew install proctools'"
exit 1
fi

if [ "$(pgrep -if 'python main.py')" ]; then
echo "Killing existing server to run a fresh version"
pkill -9 -f "python main.py"
fi

if [ "$(pgrep -f 'node ./tools/generate/chapter_watcher')" ]; then
if [ "$(pgrep -if 'node ./tools/generate/chapter_watcher')" ]; then
echo "Killing existing watcher to run a fresh version"
pkill -9 -f "node ./tools/generate/chapter_watcher"
fi
Expand All @@ -65,7 +70,7 @@ python main.py background &
# Sleep for a couple of seconds to make sure server is up
sleep 2
# Check website is running as won't have got feedback as backgrounded
pgrep -f "python main.py"
pgrep -if "python main.py"

echo "Installing node modules"
npm install
Expand Down Expand Up @@ -98,7 +103,7 @@ if [ "${debug}" == "1" ]; then
echo "Monitoring templates for changes"
npm run watch &

if [ "$(pgrep -f 'python main.py')" ]; then
if [ "$(pgrep -if 'python main.py')" ]; then
echo "Killing server to run a fresh version in debug mode"
pkill -9 -f "python main.py"
fi
Expand Down

0 comments on commit 90cca5b

Please sign in to comment.