Advertisement
Guest User

Untitled

a guest
Mar 28th, 2025
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.83 KB | None | 0 0
  1. #!/bin/sh
  2. set -e
  3.  
  4. shutdown() {
  5.     echo "Received shutdown signal. Initiating Sidekiq graceful shutdown..."
  6.  
  7.     # Stop Sidekiq from pulling new jobs
  8.     echo "Sending TSTP signal to Sidekiq..."
  9.     kill -TSTP $SIDEKIQ_PID
  10.  
  11.     # Allow some time for running jobs to complete
  12.     echo "Waiting 10 seconds before sending TERM..."
  13.     sleep 10
  14.  
  15.     # Send TERM signal to allow Sidekiq to exit gracefully
  16.     echo "Sending TERM signal to Sidekiq..."
  17.     kill -TERM $SIDEKIQ_PID
  18.  
  19.     # Wait for Sidekiq to exit
  20.     wait $SIDEKIQ_PID
  21.     echo "Sidekiq shutdown complete."
  22.     exit 0
  23. }
  24.  
  25. # Trap termination signals to handle graceful shutdown
  26. trap 'shutdown' SIGTERM SIGINT
  27.  
  28. # Start Sidekiq in the background
  29. echo "Starting Sidekiq..."
  30. bundle exec sidekiq -t 30 &
  31.  
  32. # Store the Sidekiq process ID
  33. SIDEKIQ_PID=$!
  34. wait $SIDEKIQ_PID
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement