Skip to content

Commit 90cca5b

Browse files
authored
Pgrep improvements (#3590)
1 parent c30bec6 commit 90cca5b

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/tools/scripts/deploy.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ function check_continue {
6464
fi
6565
}
6666

67+
if [ ! "$(which pgrep)" ]; then
68+
echo "Need pgrep installed. Try 'brew install proctools'"
69+
exit 1
70+
fi
71+
6772
echo "Beginning the Web Almanac deployment process"
6873

6974
# This script must be run from src directory
@@ -95,7 +100,7 @@ git status
95100
git pull
96101
git pull origin main
97102

98-
if [ "$(pgrep -f 'python main.py')" ]; then
103+
if [ "$(pgrep -if 'python main.py')" ]; then
99104
echo "Killing existing server to run a fresh version"
100105
pkill -9 python main.py
101106
fi
@@ -192,7 +197,7 @@ git status
192197
echo "Checking out main branch"
193198
git checkout main
194199

195-
if [ "$(pgrep -f 'python main.py')" ]; then
200+
if [ "$(pgrep -if 'python main.py')" ]; then
196201
echo "Killing server so backgrounded version isn't left there"
197202
pkill -9 -f "python main.py"
198203
fi

src/tools/scripts/run_and_test_website.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,17 @@ if [ -d "src" ]; then
4646
cd src
4747
fi
4848

49-
if [ "$(pgrep -f 'python main.py')" ]; then
49+
if [ ! "$(which pgrep)" ]; then
50+
echo "Need pgrep installed. Try 'brew install proctools'"
51+
exit 1
52+
fi
53+
54+
if [ "$(pgrep -if 'python main.py')" ]; then
5055
echo "Killing existing server to run a fresh version"
5156
pkill -9 -f "python main.py"
5257
fi
5358

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

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

101-
if [ "$(pgrep -f 'python main.py')" ]; then
106+
if [ "$(pgrep -if 'python main.py')" ]; then
102107
echo "Killing server to run a fresh version in debug mode"
103108
pkill -9 -f "python main.py"
104109
fi

0 commit comments

Comments
 (0)