A lot of small fixes, improvements on startup tests, migration

This commit is contained in:
kexkey
2021-11-27 00:31:18 -05:00
parent bfd9261890
commit ef4cd781da
17 changed files with 178 additions and 82 deletions

View File

@@ -11,7 +11,7 @@ compute_fees() {
trace "[compute_fees] pruned=${pruned}"
# We want null instead of 0.00000000 in this case.
echo "null"
exit 0
return
fi
local txid=${1}

View File

@@ -771,9 +771,10 @@ main() {
fi
done
trace "[main] exiting"
return 0
return ${returncode}
}
main
returncode=$?
trace "[requesthandler] exiting"
exit $?
exit ${returncode}

View File

@@ -1,5 +1,7 @@
#!/bin/sh
. ./trace.sh
trim() {
echo -e "$1" | sed -e 's/^[[:space:]]*//' | sed -e 's/[[:space:]]*$//'
}
@@ -7,12 +9,12 @@ trim() {
createCurlConfig() {
if [[ ''$1 == '' ]]; then
echo "Missing file name: Check your *_BTC_NODE_RPC_CFG"
trace "[startproxy] Missing file name: Check your *_BTC_NODE_RPC_CFG"
return
fi
if [[ ''$2 == '' ]]; then
echo "Missing content: Check your *_BTC_NODE_RPC_USER"
trace "[startproxy] Missing content: Check your *_BTC_NODE_RPC_USER"
return
fi
@@ -21,17 +23,45 @@ createCurlConfig() {
}
if [ -e ${DB_PATH}/.dbfailed ]; then
touch /container_monitor/proxy_dbfailed
trace "[startproxy] A previous database creation/migration failed. Stopping."
trace "[startproxy] A file called .dbfailed has been created. Fix the migration errors, remove .dbfailed and retry."
trace "[startproxy] Exiting."
sleep 30
exit 1
else
rm -f /container_monitor/proxy_dbfailed
fi
if [ ! -e ${DB_FILE} ]; then
echo "DB not found, creating..."
trace "[startproxy] DB not found, creating..."
cat cyphernode.sql | sqlite3 $DB_FILE
psql -h postgres -f cyphernode.postgresql -U cyphernode
returncode=$?
trace_rc ${returncode}
else
echo "DB found, migrating..."
trace "[startproxy] DB found, migrating..."
for script in sqlmigrate*.sh; do
sh $script
returncode=$?
trace_rc ${returncode}
if [ "${returncode}" -ne "0" ]; then
break
fi
done
fi
if [ "${returncode}" -ne "0" ]; then
touch ${DB_PATH}/.dbfailed
touch /container_monitor/proxy_dbfailed
trace "[startproxy] Database creation/migration failed. Stopping."
trace "[startproxy] A file called .dbfailed has been created in your proxy datapath. Fix the migration errors, remove .dbfailed and retry."
trace "[startproxy] Exiting."
sleep 30
exit ${returncode}
fi
chmod 0600 $DB_FILE
createCurlConfig ${WATCHER_BTC_NODE_RPC_CFG} ${WATCHER_BTC_NODE_RPC_USER}

View File

@@ -1,7 +1,6 @@
#!/bin/sh
trace()
{
trace() {
if [ -n "${TRACING}" ]; then
local str="$(date -Is) $$ ${1}"
echo "${str}" 1>&2
@@ -9,8 +8,7 @@ trace()
fi
}
trace_rc()
{
trace_rc() {
if [ -n "${TRACING}" ]; then
local str="$(date -Is) $$ Last return code: ${1}"
echo "${str}" 1>&2