Updated scirpts for Hot Fix
This commit is contained in:
@@ -3,55 +3,59 @@
|
||||
# QuecWatch Daemon
|
||||
# Monitors cellular connectivity and performs recovery actions
|
||||
|
||||
# Load UCI configuration functions
|
||||
. /lib/functions.sh
|
||||
|
||||
# Load centralized logging
|
||||
. /www/cgi-bin/services/quecmanager_logger.sh
|
||||
|
||||
# Load UCI configuration functions
|
||||
. /lib/functions.sh
|
||||
|
||||
# Configuration
|
||||
QUEUE_DIR="/tmp/at_queue"
|
||||
TOKEN_FILE="$QUEUE_DIR/token"
|
||||
LOG_DIR="/tmp/log/quecwatch"
|
||||
LOG_FILE="$LOG_DIR/quecwatch.log"
|
||||
PID_FILE="/var/run/quecwatch.pid"
|
||||
STATUS_FILE="/tmp/quecwatch_status.json"
|
||||
RETRY_COUNT_FILE="/tmp/quecwatch_retry_count"
|
||||
UCI_CONFIG="quecmanager"
|
||||
MAX_TOKEN_WAIT=10 # Maximum seconds to wait for token acquisition
|
||||
TOKEN_PRIORITY=15 # Medium priority (between profiles and metrics)
|
||||
SCRIPT_NAME="quecwatch"
|
||||
SCRIPT_NAME_LOG="quecwatch"
|
||||
|
||||
# Ensure directories exist
|
||||
mkdir -p "$QUEUE_DIR"
|
||||
mkdir -p "$LOG_DIR" "$QUEUE_DIR"
|
||||
|
||||
# Store PID
|
||||
echo "$$" > "$PID_FILE"
|
||||
chmod 644 "$PID_FILE"
|
||||
|
||||
# Function to log messages
|
||||
# Function to log messages - now uses centralized logging
|
||||
log_message() {
|
||||
local level="${2:-info}"
|
||||
local message="$1"
|
||||
local timestamp=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
|
||||
# Use centralized logging
|
||||
case "$level" in
|
||||
"error")
|
||||
qm_log_error "service" "$SCRIPT_NAME" "$message"
|
||||
qm_log_error "service" "$SCRIPT_NAME_LOG" "$message"
|
||||
;;
|
||||
"warn")
|
||||
qm_log_warn "service" "$SCRIPT_NAME" "$message"
|
||||
qm_log_warn "service" "$SCRIPT_NAME_LOG" "$message"
|
||||
;;
|
||||
"debug")
|
||||
qm_log_debug "service" "$SCRIPT_NAME" "$message"
|
||||
qm_log_debug "service" "$SCRIPT_NAME_LOG" "$message"
|
||||
;;
|
||||
*)
|
||||
qm_log_info "service" "$SCRIPT_NAME" "$message"
|
||||
qm_log_info "service" "$SCRIPT_NAME_LOG" "$message"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Also log to system log for important messages
|
||||
if [ "$level" = "error" ] || [ "$level" = "warn" ] || [ "$level" = "info" ]; then
|
||||
logger -t quecwatch -p "daemon.$level" "$message"
|
||||
fi
|
||||
# Also maintain system logging for compatibility
|
||||
logger -t quecwatch -p "daemon.$level" "$message"
|
||||
|
||||
# Log to file (maintain existing behavior)
|
||||
echo "[$timestamp] [$level] $message" >> "$LOG_FILE"
|
||||
}
|
||||
|
||||
# Function to update status
|
||||
|
||||
Reference in New Issue
Block a user