Skip to content

Commit

Permalink
refactor: update lockfile name in command_monitor.sh
Browse files Browse the repository at this point in the history
The lockfile name has been changed from "${selfname}-started.lock" to "${selfname}-monitoring.lock" in the fn_monitor_check_lockfile function. The code has also been refactored to remove unnecessary checks and fixes for the lockfile.
  • Loading branch information
dgibbs64 committed Jul 30, 2023
1 parent b7d9e1b commit d09c4f5
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lgsm/modules/command_monitor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ commandaction="Monitoring"
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_firstcommand_set

fn_monitor_check_lockfile() {
fn_monitor_check_monitoring() {
# Monitor does not run if lockfile is not found.
if [ ! -f "${lockdir}/${selfname}-started.lock" ]; then
if [ ! -f "${lockdir}/${selfname}-monitoring.lock" ]; then
fn_print_dots "Checking lockfile: "
fn_print_checking_eol
fn_script_log_info "Checking lockfile: CHECKING"
Expand All @@ -23,13 +23,6 @@ fn_monitor_check_lockfile() {
echo -e "* Start ${selfname} to run monitor."
core_exit.sh
fi

# Fix if lockfile is not unix time or contains letters
if [ -f "${lockdir}/${selfname}-started.lock" ] && [[ "$(head -n 1 "${lockdir}/${selfname}-started.lock")" =~ [A-Za-z] ]]; then
date '+%s' > "${lockdir:?}/${selfname}-started.lock"
echo "${version}" >> "${lockdir}/${selfname}-started.lock"
echo "${port}" >> "${lockdir}/${selfname}-started.lock"
fi
}

fn_monitor_check_install() {
Expand Down Expand Up @@ -353,7 +346,7 @@ fn_monitor_check_update_source
fn_monitor_check_update
fn_monitor_check_backup
fn_monitor_check_debug
fn_monitor_check_lockfile
fn_monitor_check_monitoring
fn_monitor_check_starting
fn_monitor_check_stopping
fn_monitor_check_session
Expand Down

0 comments on commit d09c4f5

Please sign in to comment.