Release v.1.0.25270.1 #1
@@ -6,7 +6,6 @@ REPO_LOCAL_PATH="/opt/src"
|
||||
BRANCH_NAME="develop"
|
||||
POLL_INTERVAL=60 # Seconds between checks
|
||||
#LOG_FILE="/var/log/git-monitor.log" # Log file for recording actions
|
||||
LOCK_FILE="/tmp/git-monitor.lock" # File to prevent multiple instances running concurrently
|
||||
IFS="|"
|
||||
|
||||
# Functions
|
||||
@@ -18,21 +17,6 @@ log_message() {
|
||||
echo "$timestamp [$level] $message" # Also print to console (optional)
|
||||
}
|
||||
|
||||
check_lock() {
|
||||
if [ -f "$LOCK_FILE" ]; then
|
||||
log_message "WARN" "Another instance is already running. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
create_lock() {
|
||||
touch "$LOCK_FILE"
|
||||
}
|
||||
|
||||
remove_lock() {
|
||||
rm -f "$LOCK_FILE"
|
||||
}
|
||||
|
||||
run_after() {
|
||||
local after_pull_script=$1
|
||||
source $after_pull_script
|
||||
@@ -83,9 +67,6 @@ check_for_updates() {
|
||||
}
|
||||
|
||||
# Main Execution
|
||||
check_lock
|
||||
create_lock
|
||||
|
||||
log_message "INFO" "Git monitor started."
|
||||
|
||||
initialize_repos
|
||||
@@ -99,5 +80,3 @@ while true; do
|
||||
done < $REPO_URLS
|
||||
sleep "$POLL_INTERVAL"
|
||||
done
|
||||
|
||||
remove_lock # This won't be reached in this infinite loop. Useful if exiting gracefully.
|
||||
|
||||
@@ -4,7 +4,9 @@ After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/bin/git-monitor
|
||||
LockFile=/run/git-monitor-lock
|
||||
Restart=on-failure
|
||||
RemovalPolicy=onFailure
|
||||
User=monitor
|
||||
WorkingDirectory=/opt/src
|
||||
|
||||
|
||||
Reference in New Issue
Block a user