-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to gracefully reload Gunicorn without downtime
- Loading branch information
1 parent
b8f4e42
commit 07b5ba9
Showing
1 changed file
with
20 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,21 @@ | ||
#!/usr/bin/env bash | ||
# Gracefully reloads Gunicorn. | ||
#!/bin/bash | ||
|
||
pgrep gunicorn | awk '{ print $2 }' | xargs kill -HUP | ||
# Find the Gunicorn master process ID | ||
GUNICORN_PID=$(pgrep -f 'gunicorn --bind') | ||
|
||
# Check if the PID was found | ||
if [ -z "$GUNICORN_PID" ]; then | ||
echo "Gunicorn master process not found." | ||
exit 1 | ||
fi | ||
|
||
# Send the SIGHUP signal to the Gunicorn master process | ||
kill -HUP "$GUNICORN_PID" | ||
|
||
# Check if the signal was sent successfully | ||
if [ $? -eq 0 ]; then | ||
echo "Gunicorn master process reloaded successfully." | ||
else | ||
echo "Failed to reload Gunicorn master process." | ||
exit 1 | ||
fi |