feat: new stuff
This commit is contained in:
50
start_taskiq.sh
Executable file
50
start_taskiq.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Load Redis password from .env file
|
||||
export REDIS_PASSWORD=$(grep -m 1 'REDIS_PASSWORD' .env | cut -d '=' -f2)
|
||||
|
||||
# Color definitions for log messages
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[0;33m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Function to print log messages with colors
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO] $1${NC}"
|
||||
}
|
||||
|
||||
log_warning() {
|
||||
echo -e "${YELLOW}[WARNING] $1${NC}"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR] $1${NC}"
|
||||
}
|
||||
|
||||
# Start clearing Redis locks
|
||||
log_info "Clearing Redis locks..."
|
||||
|
||||
# Check if Redis password was set correctly
|
||||
if [ -z "$REDIS_PASSWORD" ]; then
|
||||
log_error "REDIS_PASSWORD not set. Please check your .env file."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Deleting keys and getting the total deleted count
|
||||
TOTAL_DELETED_KEYS=$(redis-cli -a "$REDIS_PASSWORD" --scan --pattern '*_lock' 2>/dev/null | \
|
||||
xargs -I {} redis-cli -a "$REDIS_PASSWORD" del {} 2>/dev/null | wc -l)
|
||||
|
||||
# Log the result
|
||||
if [ "$TOTAL_DELETED_KEYS" -gt 0 ]; then
|
||||
log_info "Total deleted keys: $TOTAL_DELETED_KEYS"
|
||||
else
|
||||
log_warning "No keys matched the pattern '*_lock'."
|
||||
fi
|
||||
|
||||
# Start the Taskiq worker
|
||||
log_info "Starting Taskiq worker..."
|
||||
taskiq worker background:taskiq_broker background.tasks
|
||||
|
||||
# Log when the Taskiq worker stops
|
||||
log_info "Taskiq worker stopped"
|
||||
Reference in New Issue
Block a user