Skip to content

Commit 07b5ba9

Browse files
committed
Add script to gracefully reload Gunicorn without downtime
1 parent b8f4e42 commit 07b5ba9

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed
Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1-
#!/usr/bin/env bash
2-
# Gracefully reloads Gunicorn.
1+
#!/bin/bash
32

4-
pgrep gunicorn | awk '{ print $2 }' | xargs kill -HUP
3+
# Find the Gunicorn master process ID
4+
GUNICORN_PID=$(pgrep -f 'gunicorn --bind')
5+
6+
# Check if the PID was found
7+
if [ -z "$GUNICORN_PID" ]; then
8+
echo "Gunicorn master process not found."
9+
exit 1
10+
fi
11+
12+
# Send the SIGHUP signal to the Gunicorn master process
13+
kill -HUP "$GUNICORN_PID"
14+
15+
# Check if the signal was sent successfully
16+
if [ $? -eq 0 ]; then
17+
echo "Gunicorn master process reloaded successfully."
18+
else
19+
echo "Failed to reload Gunicorn master process."
20+
exit 1
21+
fi

0 commit comments

Comments
 (0)