From 57ad06bf7fc4bddea88daee6ecd7b2de4bb9ed41 Mon Sep 17 00:00:00 2001 From: joeuhren <46763106+joeuhren@users.noreply.github.com> Date: Sat, 5 Dec 2020 18:08:50 -0700 Subject: [PATCH] Sync script now handles db_index lock file exists issue --- scripts/sync.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/sync.sh b/scripts/sync.sh index 345a7f5..0c42062 100755 --- a/scripts/sync.sh +++ b/scripts/sync.sh @@ -105,6 +105,19 @@ if [ -n "${MODE}" ]; then rm "${EXPLORER_PATH}/tmp/index.pid" fi fi + # Check if the script is already running (tmp/db_index.pid file already exists) + if [ -f "${EXPLORER_PATH}/tmp/db_index.pid" ]; then + # The tmp/db_index.pid file exists. Check if the process is actually still running + ps -p `cat ${EXPLORER_PATH}/tmp/db_index.pid` > /dev/null + if [ $? -eq 0 ]; then + # Script is running so the data is locked and we must exit now and try again later + echo "Script already running.." + exit 1 + else + # Script is not actually running so we can delete the lock file + rm "${EXPLORER_PATH}/tmp/db_index.pid" + fi + fi fi # Check if the node path was specified if [ -z "${NODE_PATH}" ]; then