Skip to content

Commit

Permalink
Add script to gracefully reload Gunicorn without downtime
Browse files Browse the repository at this point in the history
  • Loading branch information
AyomideA-S committed Aug 24, 2024
1 parent b8f4e42 commit 07b5ba9
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions 0x1A-application_server/4-reload_gunicorn_no_downtime
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

0 comments on commit 07b5ba9

Please sign in to comment.