From d09c4f5a4fe10cd91e1d1a465575566f1f45c1fe Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 30 Jul 2023 23:51:13 +0100 Subject: [PATCH] refactor: update lockfile name in command_monitor.sh 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. --- lgsm/modules/command_monitor.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lgsm/modules/command_monitor.sh b/lgsm/modules/command_monitor.sh index c50ce4358..6e043c78b 100644 --- a/lgsm/modules/command_monitor.sh +++ b/lgsm/modules/command_monitor.sh @@ -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" @@ -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() { @@ -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