Browse Source

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
pull/4296/head
Daniel Gibbs 2 years ago
parent
commit
2cbfb5f95f
  1. 2
      lgsm/modules/command_monitor.sh
  2. 8
      lgsm/modules/command_start.sh
  3. 2
      lgsm/modules/core_exit.sh

2
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"

8
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"

2
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
}

Loading…
Cancel
Save