Browse Source

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.
pull/4296/head
Daniel Gibbs 2 years ago
parent
commit
d09c4f5a4f
  1. 13
      lgsm/modules/command_monitor.sh

13
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

Loading…
Cancel
Save