Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- set -e
- shutdown() {
- echo "Received shutdown signal. Initiating Sidekiq graceful shutdown..."
- # Stop Sidekiq from pulling new jobs
- echo "Sending TSTP signal to Sidekiq..."
- kill -TSTP $SIDEKIQ_PID
- # Allow some time for running jobs to complete
- echo "Waiting 10 seconds before sending TERM..."
- sleep 10
- # Send TERM signal to allow Sidekiq to exit gracefully
- echo "Sending TERM signal to Sidekiq..."
- kill -TERM $SIDEKIQ_PID
- # Wait for Sidekiq to exit
- wait $SIDEKIQ_PID
- echo "Sidekiq shutdown complete."
- exit 0
- }
- # Trap termination signals to handle graceful shutdown
- trap 'shutdown' SIGTERM SIGINT
- # Start Sidekiq in the background
- echo "Starting Sidekiq..."
- bundle exec sidekiq -t 30 &
- # Store the Sidekiq process ID
- SIDEKIQ_PID=$!
- wait $SIDEKIQ_PID
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement