From 2cbfb5f95ff0ce2e54a1bcc75381a5511d11c475 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 30 Jul 2023 00:57:04 +0100 Subject: [PATCH] refactor: improve logging in core_exit.sh - Changed the grep command to include the -a flag to handle non-text files - Updated sed command to remove "modulefile=" from the output and redirect it to dev-debug-module-order.log --- lgsm/modules/command_monitor.sh | 2 ++ lgsm/modules/command_start.sh | 8 ++++---- lgsm/modules/core_exit.sh | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lgsm/modules/command_monitor.sh b/lgsm/modules/command_monitor.sh index d6ab71f03..ac7c0a5c5 100644 --- a/lgsm/modules/command_monitor.sh +++ b/lgsm/modules/command_monitor.sh @@ -59,6 +59,7 @@ fn_monitor_check_backup() { # Remove stale lockfile. if [ -f "${lockdir}/backup.lock" ]; then if [ "$(find "${lockdir}/backup.lock" -mmin +60)" ]; then + fn_print_dots "Checking backup: " fn_print_warn "Checking backup: Removing stale lockfile: " fn_print_warn_eol fn_script_log_warn "Checking backup: Removing stale lockfile" @@ -68,6 +69,7 @@ fn_monitor_check_backup() { # Monitor will check if backup is running. if [ -f "${lockdir}/backup.lock" ] && [[ "$(pgrep -fc -u "${USER}" "${selfname} backup")" != "0" || "$(pgrep -fc -u "${USER}" "${selfname} b")" != "0" ]]; then + fn_print_dots "Checking backup: " fn_print_info "Checking backup: LinuxGSM is currently running a backup: " fn_print_info_eol fn_script_log_info "Checking backup: LinuxGSM is currently running a backup" diff --git a/lgsm/modules/command_start.sh b/lgsm/modules/command_start.sh index 6cb0ee8eb..4badf8ea8 100644 --- a/lgsm/modules/command_start.sh +++ b/lgsm/modules/command_start.sh @@ -43,10 +43,6 @@ fn_start_tmux() { mv "${consolelog}" "${consolelogdate}" fi - # Create start lockfile that exists only when the server is running. - date '+%s' > "${lockdir}/${selfname}-start.lock" - echo "${version}" >> "${lockdir}/${selfname}-start.lock" - echo "${port}" >> "${lockdir}/${selfname}-start.lock" fn_reload_startparameters # Create uid to ensure unique tmux socket name. @@ -164,6 +160,10 @@ fn_start_tmux() { else fn_print_ok "${servername}" fn_script_log_pass "Started ${servername}" + # Create start lockfile that exists only when the server is running. + date '+%s' > "${lockdir}/${selfname}-start.lock" + echo "${version}" >> "${lockdir}/${selfname}-start.lock" + echo "${port}" >> "${lockdir}/${selfname}-start.lock" fi rm -f "${lgsmlogdir:?}/.${selfname}-tmux-error.tmp" 2> /dev/null echo -en "\n" diff --git a/lgsm/modules/core_exit.sh b/lgsm/modules/core_exit.sh index d43f0555a..a66744b19 100644 --- a/lgsm/modules/core_exit.sh +++ b/lgsm/modules/core_exit.sh @@ -12,7 +12,7 @@ fn_exit_dev_debug() { echo -e "" echo -e "${moduleselfname} exiting with code: ${exitcode}" if [ -f "${rootdir}/dev-debug.log" ]; then - grep "modulefile=" "${rootdir}/dev-debug.log" | sed 's/modulefile=//g' > "${rootdir}/dev-debug-module-order.log" + grep -a "modulefile=" "${rootdir}/dev-debug.log" | sed 's/modulefile=//g' > "${rootdir}/dev-debug-module-order.log" fi fi }