mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-29 10:35:21 +01:00
A lot of small fixes, improvements on startup tests, migration
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -771,9 +771,10 @@ main() {
|
||||
fi
|
||||
done
|
||||
trace "[main] exiting"
|
||||
return 0
|
||||
return ${returncode}
|
||||
}
|
||||
|
||||
main
|
||||
returncode=$?
|
||||
trace "[requesthandler] exiting"
|
||||
exit $?
|
||||
exit ${returncode}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user