Compare commits
11 Commits
master
...
bvander/co
Author | SHA1 | Date | |
---|---|---|---|
4cd3f12f22 | |||
ad25e0a38d | |||
e3144cb780 | |||
f70259a25d | |||
e7e697c7db | |||
34d4c9389c | |||
cca20046c8 | |||
503934037f | |||
b6b986e905 | |||
de02b12424 | |||
a062fa1e6f |
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,3 +15,4 @@ build/
|
||||
.idea
|
||||
**/.vim
|
||||
**/*secret.yaml
|
||||
**/*.bash_history
|
||||
|
@ -19,6 +19,11 @@ Run app/contract-migration to deploy contracts
|
||||
RUN_MASK=3 docker-compose up contract-migration
|
||||
```
|
||||
|
||||
View container status
|
||||
```
|
||||
docker ps --filter network=cic-network --format "table {{.ID}}\t{{.Names}}\t{{.Status}}" --all
|
||||
```
|
||||
|
||||
stop cluster
|
||||
```
|
||||
docker-compose down
|
||||
|
10
apps/cic-cache/docker/get_readyz.sh
Executable file
10
apps/cic-cache/docker/get_readyz.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
echo "fetching migration variables from $CONTRACT_MIGRATION_URL"
|
||||
for s in $(curl -s "$CONTRACT_MIGRATION_URL/readyz" | jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" ); do
|
||||
echo "exporting $s"
|
||||
export $s
|
||||
done
|
23
apps/cic-cache/docker/start_server.sh
Normal file
23
apps/cic-cache/docker/start_server.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
WAIT_FOR_TIMEOUT=${WAIT_FOR_TIMEOUT:-600}
|
||||
|
||||
. ./db.sh
|
||||
|
||||
if [ $? -ne "0" ]; then
|
||||
>&2 echo db migrate fail
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$CONTRACT_MIGRATION_URL" ]]; then
|
||||
echo "waiting for $CONTRACT_MIGRATION_URL/readyz"
|
||||
./wait-for-it.sh $CONTRACT_MIGRATION_URL -t $WAIT_FOR_TIMEOUT
|
||||
source ./get_readyz.sh # set env vars form endpoint
|
||||
/usr/local/bin/uwsgi --wsgi-file /root/cic_cache/runnable/daemons/server.py --http :8000 --pyargv "-vv"
|
||||
else
|
||||
/usr/local/bin/uwsgi --wsgi-file /root/cic_cache/runnable/daemons/server.py --http :8000 --pyargv "-vv"
|
||||
fi
|
||||
|
23
apps/cic-cache/docker/start_tasker.sh
Normal file
23
apps/cic-cache/docker/start_tasker.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
WAIT_FOR_TIMEOUT=${WAIT_FOR_TIMEOUT:-600}
|
||||
|
||||
. ./db.sh
|
||||
|
||||
if [ $? -ne "0" ]; then
|
||||
>&2 echo db migrate fail
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$CONTRACT_MIGRATION_URL" ]]; then
|
||||
echo "waiting for $CONTRACT_MIGRATION_URL/readyz"
|
||||
./wait-for-it.sh $CONTRACT_MIGRATION_URL -t $WAIT_FOR_TIMEOUT
|
||||
source ./get_readyz.sh # set env vars form endpoint
|
||||
/usr/local/bin/cic-cache-taskerd -vv
|
||||
else
|
||||
/usr/local/bin/cic-cache-taskerd -vv
|
||||
fi
|
||||
|
@ -1,5 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
WAIT_FOR_TIMEOUT=${WAIT_FOR_TIMEOUT:-600}
|
||||
|
||||
. ./db.sh
|
||||
|
||||
if [ $? -ne "0" ]; then
|
||||
@ -7,4 +12,12 @@ if [ $? -ne "0" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$CONTRACT_MIGRATION_URL" ]]; then
|
||||
echo "waiting for $CONTRACT_MIGRATION_URL/readyz"
|
||||
docker/wait-for-it.sh $CONTRACT_MIGRATION_URL -t $WAIT_FOR_TIMEOUT
|
||||
source docker/get_readyz.sh # set env vars form endpoint
|
||||
/usr/local/bin/cic-cache-trackerd $@
|
||||
else
|
||||
/usr/local/bin/cic-cache-trackerd $@
|
||||
fi
|
||||
|
||||
|
182
apps/cic-cache/docker/wait-for-it.sh
Executable file
182
apps/cic-cache/docker/wait-for-it.sh
Executable file
@ -0,0 +1,182 @@
|
||||
#!/usr/bin/env bash
|
||||
# Use this script to test if a given TCP host/port are available
|
||||
|
||||
WAITFORIT_cmdname=${0##*/}
|
||||
|
||||
echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << USAGE >&2
|
||||
Usage:
|
||||
$WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args]
|
||||
-h HOST | --host=HOST Host or IP under test
|
||||
-p PORT | --port=PORT TCP port under test
|
||||
Alternatively, you specify the host and port as host:port
|
||||
-s | --strict Only execute subcommand if the test succeeds
|
||||
-q | --quiet Don't output any status messages
|
||||
-t TIMEOUT | --timeout=TIMEOUT
|
||||
Timeout in seconds, zero for no timeout
|
||||
-- COMMAND ARGS Execute command with args after the test finishes
|
||||
USAGE
|
||||
exit 1
|
||||
}
|
||||
|
||||
wait_for()
|
||||
{
|
||||
if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
|
||||
echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
|
||||
else
|
||||
echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout"
|
||||
fi
|
||||
WAITFORIT_start_ts=$(date +%s)
|
||||
while :
|
||||
do
|
||||
if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then
|
||||
nc -z $WAITFORIT_HOST $WAITFORIT_PORT
|
||||
WAITFORIT_result=$?
|
||||
else
|
||||
(echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1
|
||||
WAITFORIT_result=$?
|
||||
fi
|
||||
if [[ $WAITFORIT_result -eq 0 ]]; then
|
||||
WAITFORIT_end_ts=$(date +%s)
|
||||
echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds"
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
return $WAITFORIT_result
|
||||
}
|
||||
|
||||
wait_for_wrapper()
|
||||
{
|
||||
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
|
||||
if [[ $WAITFORIT_QUIET -eq 1 ]]; then
|
||||
timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
|
||||
else
|
||||
timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
|
||||
fi
|
||||
WAITFORIT_PID=$!
|
||||
trap "kill -INT -$WAITFORIT_PID" INT
|
||||
wait $WAITFORIT_PID
|
||||
WAITFORIT_RESULT=$?
|
||||
if [[ $WAITFORIT_RESULT -ne 0 ]]; then
|
||||
echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
|
||||
fi
|
||||
return $WAITFORIT_RESULT
|
||||
}
|
||||
|
||||
# process arguments
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case "$1" in
|
||||
*:* )
|
||||
WAITFORIT_hostport=(${1//:/ })
|
||||
WAITFORIT_HOST=${WAITFORIT_hostport[0]}
|
||||
WAITFORIT_PORT=${WAITFORIT_hostport[1]}
|
||||
shift 1
|
||||
;;
|
||||
--child)
|
||||
WAITFORIT_CHILD=1
|
||||
shift 1
|
||||
;;
|
||||
-q | --quiet)
|
||||
WAITFORIT_QUIET=1
|
||||
shift 1
|
||||
;;
|
||||
-s | --strict)
|
||||
WAITFORIT_STRICT=1
|
||||
shift 1
|
||||
;;
|
||||
-h)
|
||||
WAITFORIT_HOST="$2"
|
||||
if [[ $WAITFORIT_HOST == "" ]]; then break; fi
|
||||
shift 2
|
||||
;;
|
||||
--host=*)
|
||||
WAITFORIT_HOST="${1#*=}"
|
||||
shift 1
|
||||
;;
|
||||
-p)
|
||||
WAITFORIT_PORT="$2"
|
||||
if [[ $WAITFORIT_PORT == "" ]]; then break; fi
|
||||
shift 2
|
||||
;;
|
||||
--port=*)
|
||||
WAITFORIT_PORT="${1#*=}"
|
||||
shift 1
|
||||
;;
|
||||
-t)
|
||||
WAITFORIT_TIMEOUT="$2"
|
||||
if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi
|
||||
shift 2
|
||||
;;
|
||||
--timeout=*)
|
||||
WAITFORIT_TIMEOUT="${1#*=}"
|
||||
shift 1
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
WAITFORIT_CLI=("$@")
|
||||
break
|
||||
;;
|
||||
--help)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
echoerr "Unknown argument: $1"
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then
|
||||
echoerr "Error: you need to provide a host and port to test."
|
||||
usage
|
||||
fi
|
||||
|
||||
WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15}
|
||||
WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
|
||||
WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
|
||||
WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}
|
||||
|
||||
# Check to see if timeout is from busybox?
|
||||
WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
|
||||
WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
|
||||
|
||||
WAITFORIT_BUSYTIMEFLAG=""
|
||||
if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
|
||||
WAITFORIT_ISBUSY=1
|
||||
# Check if busybox timeout uses -t flag
|
||||
# (recent Alpine versions don't support -t anymore)
|
||||
if timeout &>/dev/stdout | grep -q -e '-t '; then
|
||||
WAITFORIT_BUSYTIMEFLAG="-t"
|
||||
fi
|
||||
else
|
||||
WAITFORIT_ISBUSY=0
|
||||
fi
|
||||
|
||||
if [[ $WAITFORIT_CHILD -gt 0 ]]; then
|
||||
wait_for
|
||||
WAITFORIT_RESULT=$?
|
||||
exit $WAITFORIT_RESULT
|
||||
else
|
||||
if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
|
||||
wait_for_wrapper
|
||||
WAITFORIT_RESULT=$?
|
||||
else
|
||||
wait_for
|
||||
WAITFORIT_RESULT=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $WAITFORIT_CLI != "" ]]; then
|
||||
if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then
|
||||
echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess"
|
||||
exit $WAITFORIT_RESULT
|
||||
fi
|
||||
exec "${WAITFORIT_CLI[@]}"
|
||||
else
|
||||
exit $WAITFORIT_RESULT
|
||||
fi
|
10
apps/cic-eth/docker/entrypoints/get_readyz.sh
Executable file
10
apps/cic-eth/docker/entrypoints/get_readyz.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
echo "fetching migration variables from $CONTRACT_MIGRATION_URL"
|
||||
for s in $(curl -s "$CONTRACT_MIGRATION_URL/readyz" | jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" ); do
|
||||
echo "exporting $s"
|
||||
export $s
|
||||
done
|
@ -1,5 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
. ./db.sh
|
||||
|
||||
WAIT_FOR_TIMEOUT=${WAIT_FOR_TIMEOUT:-600}
|
||||
|
||||
if [[ "$CONTRACT_MIGRATION_URL" ]]; then
|
||||
echo "waiting for $CONTRACT_MIGRATION_URL/readyz"
|
||||
./wait-for-it.sh $CONTRACT_MIGRATION_URL -t $WAIT_FOR_TIMEOUT
|
||||
source ./get_readyz.sh # set env vars form endpoint
|
||||
/usr/local/bin/cic-eth-dispatcherd $@
|
||||
else
|
||||
/usr/local/bin/cic-eth-dispatcherd $@
|
||||
fi
|
||||
|
@ -1,5 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
. ./db.sh
|
||||
|
||||
WAIT_FOR_TIMEOUT=${WAIT_FOR_TIMEOUT:-600}
|
||||
|
||||
|
||||
if [[ "$CONTRACT_MIGRATION_URL" ]]; then
|
||||
echo "waiting for $CONTRACT_MIGRATION_URL/readyz"
|
||||
./wait-for-it.sh $CONTRACT_MIGRATION_URL -t $WAIT_FOR_TIMEOUT
|
||||
source ./get_readyz.sh # set env vars form endpoint
|
||||
/usr/local/bin/cic-eth-retrierd $@
|
||||
else
|
||||
/usr/local/bin/cic-eth-retrierd $@
|
||||
fi
|
||||
|
@ -1,31 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
. ./db.sh
|
||||
|
||||
# set CONFINI_ENV_PREFIX to override the env prefix to override env vars
|
||||
WAIT_FOR_TIMEOUT=${WAIT_FOR_TIMEOUT:-600}
|
||||
|
||||
#echo "!!! starting signer"
|
||||
#python /usr/local/bin/crypto-dev-daemon -c /usr/local/etc/crypto-dev-signer -vv 2> /tmp/signer.log &
|
||||
|
||||
echo "!!! starting taskerd"
|
||||
if [[ "$CONTRACT_MIGRATION_URL" ]]; then
|
||||
echo "waiting for $CONTRACT_MIGRATION_URL/readyz"
|
||||
./wait-for-it.sh $CONTRACT_MIGRATION_URL -t $WAIT_FOR_TIMEOUT
|
||||
source ./get_readyz.sh # set env vars form endpoint
|
||||
/usr/local/bin/cic-eth-taskerd $@
|
||||
|
||||
# thanks! https://docs.docker.com/config/containers/multi-service_container/
|
||||
#sleep 1;
|
||||
#echo "!!! entering monitor loop"
|
||||
#while true; do
|
||||
# ps aux | grep crypto-dev-daemon | grep -q -v grep
|
||||
# PROCESS_1_STATUS=$?
|
||||
# ps aux | grep cic-eth-tasker |grep -q -v grep
|
||||
# PROCESS_2_STATUS=$?
|
||||
# # If the greps above find anything, they exit with 0 status
|
||||
# # If they are not both 0, then something is wrong
|
||||
# if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 ]; then
|
||||
# echo "One of the processes has already exited."
|
||||
# exit 1
|
||||
# fi
|
||||
# sleep 15;
|
||||
#done
|
||||
#
|
||||
set +e
|
||||
else
|
||||
/usr/local/bin/cic-eth-taskerd $@
|
||||
fi
|
||||
|
@ -1,5 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
. ./db.sh
|
||||
|
||||
WAIT_FOR_TIMEOUT=${WAIT_FOR_TIMEOUT:-600}
|
||||
|
||||
if [[ "$CONTRACT_MIGRATION_URL" ]]; then
|
||||
echo "waiting for $CONTRACT_MIGRATION_URL/readyz"
|
||||
./wait-for-it.sh $CONTRACT_MIGRATION_URL -t $WAIT_FOR_TIMEOUT
|
||||
source ./get_readyz.sh # set env vars form endpoint
|
||||
/usr/local/bin/cic-eth-trackerd $@
|
||||
else
|
||||
/usr/local/bin/cic-eth-trackerd $@
|
||||
fi
|
||||
|
182
apps/cic-eth/docker/entrypoints/wait-for-it.sh
Executable file
182
apps/cic-eth/docker/entrypoints/wait-for-it.sh
Executable file
@ -0,0 +1,182 @@
|
||||
#!/usr/bin/env bash
|
||||
# Use this script to test if a given TCP host/port are available
|
||||
|
||||
WAITFORIT_cmdname=${0##*/}
|
||||
|
||||
echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << USAGE >&2
|
||||
Usage:
|
||||
$WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args]
|
||||
-h HOST | --host=HOST Host or IP under test
|
||||
-p PORT | --port=PORT TCP port under test
|
||||
Alternatively, you specify the host and port as host:port
|
||||
-s | --strict Only execute subcommand if the test succeeds
|
||||
-q | --quiet Don't output any status messages
|
||||
-t TIMEOUT | --timeout=TIMEOUT
|
||||
Timeout in seconds, zero for no timeout
|
||||
-- COMMAND ARGS Execute command with args after the test finishes
|
||||
USAGE
|
||||
exit 1
|
||||
}
|
||||
|
||||
wait_for()
|
||||
{
|
||||
if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
|
||||
echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
|
||||
else
|
||||
echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout"
|
||||
fi
|
||||
WAITFORIT_start_ts=$(date +%s)
|
||||
while :
|
||||
do
|
||||
if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then
|
||||
nc -z $WAITFORIT_HOST $WAITFORIT_PORT
|
||||
WAITFORIT_result=$?
|
||||
else
|
||||
(echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1
|
||||
WAITFORIT_result=$?
|
||||
fi
|
||||
if [[ $WAITFORIT_result -eq 0 ]]; then
|
||||
WAITFORIT_end_ts=$(date +%s)
|
||||
echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds"
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
return $WAITFORIT_result
|
||||
}
|
||||
|
||||
wait_for_wrapper()
|
||||
{
|
||||
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
|
||||
if [[ $WAITFORIT_QUIET -eq 1 ]]; then
|
||||
timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
|
||||
else
|
||||
timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
|
||||
fi
|
||||
WAITFORIT_PID=$!
|
||||
trap "kill -INT -$WAITFORIT_PID" INT
|
||||
wait $WAITFORIT_PID
|
||||
WAITFORIT_RESULT=$?
|
||||
if [[ $WAITFORIT_RESULT -ne 0 ]]; then
|
||||
echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
|
||||
fi
|
||||
return $WAITFORIT_RESULT
|
||||
}
|
||||
|
||||
# process arguments
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case "$1" in
|
||||
*:* )
|
||||
WAITFORIT_hostport=(${1//:/ })
|
||||
WAITFORIT_HOST=${WAITFORIT_hostport[0]}
|
||||
WAITFORIT_PORT=${WAITFORIT_hostport[1]}
|
||||
shift 1
|
||||
;;
|
||||
--child)
|
||||
WAITFORIT_CHILD=1
|
||||
shift 1
|
||||
;;
|
||||
-q | --quiet)
|
||||
WAITFORIT_QUIET=1
|
||||
shift 1
|
||||
;;
|
||||
-s | --strict)
|
||||
WAITFORIT_STRICT=1
|
||||
shift 1
|
||||
;;
|
||||
-h)
|
||||
WAITFORIT_HOST="$2"
|
||||
if [[ $WAITFORIT_HOST == "" ]]; then break; fi
|
||||
shift 2
|
||||
;;
|
||||
--host=*)
|
||||
WAITFORIT_HOST="${1#*=}"
|
||||
shift 1
|
||||
;;
|
||||
-p)
|
||||
WAITFORIT_PORT="$2"
|
||||
if [[ $WAITFORIT_PORT == "" ]]; then break; fi
|
||||
shift 2
|
||||
;;
|
||||
--port=*)
|
||||
WAITFORIT_PORT="${1#*=}"
|
||||
shift 1
|
||||
;;
|
||||
-t)
|
||||
WAITFORIT_TIMEOUT="$2"
|
||||
if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi
|
||||
shift 2
|
||||
;;
|
||||
--timeout=*)
|
||||
WAITFORIT_TIMEOUT="${1#*=}"
|
||||
shift 1
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
WAITFORIT_CLI=("$@")
|
||||
break
|
||||
;;
|
||||
--help)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
echoerr "Unknown argument: $1"
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then
|
||||
echoerr "Error: you need to provide a host and port to test."
|
||||
usage
|
||||
fi
|
||||
|
||||
WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15}
|
||||
WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
|
||||
WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
|
||||
WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}
|
||||
|
||||
# Check to see if timeout is from busybox?
|
||||
WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
|
||||
WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
|
||||
|
||||
WAITFORIT_BUSYTIMEFLAG=""
|
||||
if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
|
||||
WAITFORIT_ISBUSY=1
|
||||
# Check if busybox timeout uses -t flag
|
||||
# (recent Alpine versions don't support -t anymore)
|
||||
if timeout &>/dev/stdout | grep -q -e '-t '; then
|
||||
WAITFORIT_BUSYTIMEFLAG="-t"
|
||||
fi
|
||||
else
|
||||
WAITFORIT_ISBUSY=0
|
||||
fi
|
||||
|
||||
if [[ $WAITFORIT_CHILD -gt 0 ]]; then
|
||||
wait_for
|
||||
WAITFORIT_RESULT=$?
|
||||
exit $WAITFORIT_RESULT
|
||||
else
|
||||
if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
|
||||
wait_for_wrapper
|
||||
WAITFORIT_RESULT=$?
|
||||
else
|
||||
wait_for
|
||||
WAITFORIT_RESULT=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $WAITFORIT_CLI != "" ]]; then
|
||||
if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then
|
||||
echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess"
|
||||
exit $WAITFORIT_RESULT
|
||||
fi
|
||||
exec "${WAITFORIT_CLI[@]}"
|
||||
else
|
||||
exit $WAITFORIT_RESULT
|
||||
fi
|
10
apps/cic-ussd/docker/get_readyz.sh
Executable file
10
apps/cic-ussd/docker/get_readyz.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
echo "fetching migration variables from $CONTRACT_MIGRATION_URL"
|
||||
for s in $(curl -s "$CONTRACT_MIGRATION_URL/readyz" | jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" ); do
|
||||
echo "exporting $s"
|
||||
export $s
|
||||
done
|
182
apps/cic-ussd/docker/wait-for-it.sh
Executable file
182
apps/cic-ussd/docker/wait-for-it.sh
Executable file
@ -0,0 +1,182 @@
|
||||
#!/usr/bin/env bash
|
||||
# Use this script to test if a given TCP host/port are available
|
||||
|
||||
WAITFORIT_cmdname=${0##*/}
|
||||
|
||||
echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << USAGE >&2
|
||||
Usage:
|
||||
$WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args]
|
||||
-h HOST | --host=HOST Host or IP under test
|
||||
-p PORT | --port=PORT TCP port under test
|
||||
Alternatively, you specify the host and port as host:port
|
||||
-s | --strict Only execute subcommand if the test succeeds
|
||||
-q | --quiet Don't output any status messages
|
||||
-t TIMEOUT | --timeout=TIMEOUT
|
||||
Timeout in seconds, zero for no timeout
|
||||
-- COMMAND ARGS Execute command with args after the test finishes
|
||||
USAGE
|
||||
exit 1
|
||||
}
|
||||
|
||||
wait_for()
|
||||
{
|
||||
if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
|
||||
echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
|
||||
else
|
||||
echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout"
|
||||
fi
|
||||
WAITFORIT_start_ts=$(date +%s)
|
||||
while :
|
||||
do
|
||||
if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then
|
||||
nc -z $WAITFORIT_HOST $WAITFORIT_PORT
|
||||
WAITFORIT_result=$?
|
||||
else
|
||||
(echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1
|
||||
WAITFORIT_result=$?
|
||||
fi
|
||||
if [[ $WAITFORIT_result -eq 0 ]]; then
|
||||
WAITFORIT_end_ts=$(date +%s)
|
||||
echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds"
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
return $WAITFORIT_result
|
||||
}
|
||||
|
||||
wait_for_wrapper()
|
||||
{
|
||||
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
|
||||
if [[ $WAITFORIT_QUIET -eq 1 ]]; then
|
||||
timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
|
||||
else
|
||||
timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
|
||||
fi
|
||||
WAITFORIT_PID=$!
|
||||
trap "kill -INT -$WAITFORIT_PID" INT
|
||||
wait $WAITFORIT_PID
|
||||
WAITFORIT_RESULT=$?
|
||||
if [[ $WAITFORIT_RESULT -ne 0 ]]; then
|
||||
echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
|
||||
fi
|
||||
return $WAITFORIT_RESULT
|
||||
}
|
||||
|
||||
# process arguments
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case "$1" in
|
||||
*:* )
|
||||
WAITFORIT_hostport=(${1//:/ })
|
||||
WAITFORIT_HOST=${WAITFORIT_hostport[0]}
|
||||
WAITFORIT_PORT=${WAITFORIT_hostport[1]}
|
||||
shift 1
|
||||
;;
|
||||
--child)
|
||||
WAITFORIT_CHILD=1
|
||||
shift 1
|
||||
;;
|
||||
-q | --quiet)
|
||||
WAITFORIT_QUIET=1
|
||||
shift 1
|
||||
;;
|
||||
-s | --strict)
|
||||
WAITFORIT_STRICT=1
|
||||
shift 1
|
||||
;;
|
||||
-h)
|
||||
WAITFORIT_HOST="$2"
|
||||
if [[ $WAITFORIT_HOST == "" ]]; then break; fi
|
||||
shift 2
|
||||
;;
|
||||
--host=*)
|
||||
WAITFORIT_HOST="${1#*=}"
|
||||
shift 1
|
||||
;;
|
||||
-p)
|
||||
WAITFORIT_PORT="$2"
|
||||
if [[ $WAITFORIT_PORT == "" ]]; then break; fi
|
||||
shift 2
|
||||
;;
|
||||
--port=*)
|
||||
WAITFORIT_PORT="${1#*=}"
|
||||
shift 1
|
||||
;;
|
||||
-t)
|
||||
WAITFORIT_TIMEOUT="$2"
|
||||
if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi
|
||||
shift 2
|
||||
;;
|
||||
--timeout=*)
|
||||
WAITFORIT_TIMEOUT="${1#*=}"
|
||||
shift 1
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
WAITFORIT_CLI=("$@")
|
||||
break
|
||||
;;
|
||||
--help)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
echoerr "Unknown argument: $1"
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then
|
||||
echoerr "Error: you need to provide a host and port to test."
|
||||
usage
|
||||
fi
|
||||
|
||||
WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15}
|
||||
WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
|
||||
WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
|
||||
WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}
|
||||
|
||||
# Check to see if timeout is from busybox?
|
||||
WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
|
||||
WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
|
||||
|
||||
WAITFORIT_BUSYTIMEFLAG=""
|
||||
if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
|
||||
WAITFORIT_ISBUSY=1
|
||||
# Check if busybox timeout uses -t flag
|
||||
# (recent Alpine versions don't support -t anymore)
|
||||
if timeout &>/dev/stdout | grep -q -e '-t '; then
|
||||
WAITFORIT_BUSYTIMEFLAG="-t"
|
||||
fi
|
||||
else
|
||||
WAITFORIT_ISBUSY=0
|
||||
fi
|
||||
|
||||
if [[ $WAITFORIT_CHILD -gt 0 ]]; then
|
||||
wait_for
|
||||
WAITFORIT_RESULT=$?
|
||||
exit $WAITFORIT_RESULT
|
||||
else
|
||||
if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
|
||||
wait_for_wrapper
|
||||
WAITFORIT_RESULT=$?
|
||||
else
|
||||
wait_for
|
||||
WAITFORIT_RESULT=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $WAITFORIT_CLI != "" ]]; then
|
||||
if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then
|
||||
echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess"
|
||||
exit $WAITFORIT_RESULT
|
||||
fi
|
||||
exec "${WAITFORIT_CLI[@]}"
|
||||
else
|
||||
exit $WAITFORIT_RESULT
|
||||
fi
|
0
apps/contract-migration/config.sh
Normal file → Executable file
0
apps/contract-migration/config.sh
Normal file → Executable file
25
apps/contract-migration/docker/init_readyz.sh
Executable file
25
apps/contract-migration/docker/init_readyz.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
set -a
|
||||
|
||||
mkdir -p $DEV_DATA_DIR/health
|
||||
|
||||
source $DEV_DATA_DIR/env_reset
|
||||
|
||||
jq --arg CIC_REGISTRY_ADDRESS "$CIC_REGISTRY_ADDRESS" \
|
||||
--arg CIC_TRUST_ADDRESS "$CIC_TRUST_ADDRESS" \
|
||||
--arg CIC_DEFAULT_TOKEN_SYMBOL "$CIC_DEFAULT_TOKEN_SYMBOL"\
|
||||
--arg TOKEN_NAME "$TOKEN_NAME"\
|
||||
--arg RUN_MASK "$RUN_MASK" \
|
||||
-n '{"CIC_REGISTRY_ADDRESS": $CIC_REGISTRY_ADDRESS,
|
||||
"CIC_TRUST_ADDRESS": $CIC_TRUST_ADDRESS,
|
||||
"CIC_DEFAULT_TOKEN_SYMBOL": $CIC_DEFAULT_TOKEN_SYMBOL,
|
||||
"TOKEN_NAME": $TOKEN_NAME,
|
||||
"RUN_MASK": $RUN_MASK}' > $DEV_DATA_DIR/health/readyz
|
||||
|
||||
cd $DEV_DATA_DIR/health
|
||||
|
||||
echo "starting health endpoint on :8000/readyz"
|
||||
python -m http.server 8000 &> /dev/null
|
||||
|
16
apps/contract-migration/env_reset
Normal file
16
apps/contract-migration/env_reset
Normal file
@ -0,0 +1,16 @@
|
||||
export DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER=0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C
|
||||
export DEV_ETH_ACCOUNT_RESERVE_MINTER=0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C
|
||||
export DEV_ETH_ACCOUNT_ACCOUNTS_INDEX_WRITER=0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C
|
||||
export DEV_RESERVE_AMOUNT=10000000000000000000000000000000000
|
||||
export DEV_FAUCET_AMOUNT=50000000
|
||||
export DEV_GAS_AMOUNT=100000000000000000000000
|
||||
export DEV_TOKEN_AMOUNT=100000000000000000000000
|
||||
export DEV_ETH_GAS_PRICE=
|
||||
export DEV_DATA_DIR=.
|
||||
export DEV_PIP_EXTRA_INDEX_URL=https://pip.grassrootseconomics.net:8433
|
||||
export DEV_ETH_PROVIDER_HOST=
|
||||
export DEV_ETH_PROVIDER_PORT=
|
||||
export CIC_TRUST_ADDRESS=0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C
|
||||
export CIC_DEFAULT_TOKEN_SYMBOL=GFT
|
||||
export WALLET_KEY_FILE=/root/keystore/UTC--2021-01-08T17-18-44.521011372Z--eb3907ecad74a0013c259d5874ae7f22dcbcc95c
|
||||
|
0
apps/contract-migration/from_env.sh
Normal file → Executable file
0
apps/contract-migration/from_env.sh
Normal file → Executable file
0
apps/contract-migration/nvm.sh
Normal file → Executable file
0
apps/contract-migration/nvm.sh
Normal file → Executable file
@ -112,10 +112,16 @@ export CIC_DEFAULT_TOKEN_SYMBOL=$TOKEN_SYMBOL
|
||||
|
||||
echo "Writing env_reset file ..."
|
||||
|
||||
echo "export CIC_REGISTRY_ADDRESS=$CIC_REGISTRY_ADDRESS
|
||||
# note these are also written in init_readyz.sh
|
||||
cat <<EOF > $DEV_DATA_DIR/env_reset
|
||||
export CIC_REGISTRY_ADDRESS=$CIC_REGISTRY_ADDRESS
|
||||
export CIC_TRUST_ADDRESS=$CIC_TRUST_ADDRESS
|
||||
export CIC_DEFAULT_TOKEN_SYMBOL=$CIC_DEFAULT_TOKEN_SYMBOL
|
||||
export TOKEN_NAME=$TOKEN_NAME
|
||||
" >> "${DEV_DATA_DIR}"/env_reset
|
||||
EOF
|
||||
|
||||
confini-dump -vv --schema-module chainlib.eth.data.config --schema-module cic_eth.data.config --schema-dir ./config --prefix export > ${DEV_DATA_DIR}/env_reset
|
||||
confini-dump --schema-module chainlib.eth.data.config --schema-module cic_eth.data.config --schema-dir ./config
|
||||
|
||||
set +a
|
||||
set +e
|
||||
|
6
apps/contract-migration/run_job.sh
Normal file → Executable file
6
apps/contract-migration/run_job.sh
Normal file → Executable file
@ -12,6 +12,10 @@ if [[ $((RUN_MASK & 1)) -eq 1 ]]
|
||||
then
|
||||
>&2 echo -e "\033[;96mRUNNING\033[;39m RUN_MASK 1 - contract deployment"
|
||||
./reset.sh
|
||||
# cic-eth-xxx services rely on
|
||||
export RUN_MASK_PHASE=1
|
||||
./docker/init_readyz.sh &
|
||||
echo 0
|
||||
if [ $? -ne "0" ]; then
|
||||
>&2 echo -e "\033[;31mFAILED\033[;39m RUN_MASK 1 - contract deployment"
|
||||
exit 1;
|
||||
@ -29,3 +33,5 @@ then
|
||||
fi
|
||||
>&2 echo -e "\033[;32mSUCCEEDED\033[;39m RUN_MASK 2 - custodial service initialization"
|
||||
fi
|
||||
# this will leave the container up and serving the results of the migration
|
||||
wait
|
||||
|
@ -82,7 +82,7 @@ cic-eth-ctl -i $CHAIN_SPEC unlock INIT
|
||||
cic-eth-ctl -i $CHAIN_SPEC unlock SEND
|
||||
cic-eth-ctl -i $CHAIN_SPEC unlock QUEUE
|
||||
|
||||
#confini-dump --schema-module chainlib.eth.data.config --schema-module cic_eth.data.config --schema-dir ./config
|
||||
confini-dump --schema-module chainlib.eth.data.config --schema-module cic_eth.data.config --schema-dir ./config
|
||||
|
||||
set +a
|
||||
set +e
|
||||
|
0
apps/data-seeding/import_ussd.sh
Normal file → Executable file
0
apps/data-seeding/import_ussd.sh
Normal file → Executable file
10
apps/data-seeding/scripts/get_readyz.sh
Executable file
10
apps/data-seeding/scripts/get_readyz.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
echo "fetching migration variables from $CONTRACT_MIGRATION_URL"
|
||||
for s in $(curl -s "$CONTRACT_MIGRATION_URL/readyz" | jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" ); do
|
||||
echo "exporting $s"
|
||||
export $s
|
||||
done
|
15
apps/data-seeding/scripts/run_job.sh
Executable file
15
apps/data-seeding/scripts/run_job.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#! /bin/bash
|
||||
set -e
|
||||
set -u
|
||||
env
|
||||
WAIT_FOR_TIMEOUT=${WAIT_FOR_TIMEOUT:-600}
|
||||
|
||||
if [[ "$CONTRACT_MIGRATION_URL" ]]; then
|
||||
echo "waiting for $CONTRACT_MIGRATION_URL/readyz"
|
||||
./scripts/wait-for-it.sh $CONTRACT_MIGRATION_URL -t $WAIT_FOR_TIMEOUT
|
||||
source ./scripts/get_readyz.sh # set env vars form endpoint
|
||||
./import_ussd.sh
|
||||
else
|
||||
./import_ussd.sh
|
||||
fi
|
||||
|
0
apps/data-seeding/scripts/run_ussd_user_imports.sh
Normal file → Executable file
0
apps/data-seeding/scripts/run_ussd_user_imports.sh
Normal file → Executable file
182
apps/data-seeding/scripts/wait-for-it.sh
Executable file
182
apps/data-seeding/scripts/wait-for-it.sh
Executable file
@ -0,0 +1,182 @@
|
||||
#!/usr/bin/env bash
|
||||
# Use this script to test if a given TCP host/port are available
|
||||
|
||||
WAITFORIT_cmdname=${0##*/}
|
||||
|
||||
echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << USAGE >&2
|
||||
Usage:
|
||||
$WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args]
|
||||
-h HOST | --host=HOST Host or IP under test
|
||||
-p PORT | --port=PORT TCP port under test
|
||||
Alternatively, you specify the host and port as host:port
|
||||
-s | --strict Only execute subcommand if the test succeeds
|
||||
-q | --quiet Don't output any status messages
|
||||
-t TIMEOUT | --timeout=TIMEOUT
|
||||
Timeout in seconds, zero for no timeout
|
||||
-- COMMAND ARGS Execute command with args after the test finishes
|
||||
USAGE
|
||||
exit 1
|
||||
}
|
||||
|
||||
wait_for()
|
||||
{
|
||||
if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
|
||||
echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
|
||||
else
|
||||
echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout"
|
||||
fi
|
||||
WAITFORIT_start_ts=$(date +%s)
|
||||
while :
|
||||
do
|
||||
if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then
|
||||
nc -z $WAITFORIT_HOST $WAITFORIT_PORT
|
||||
WAITFORIT_result=$?
|
||||
else
|
||||
(echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1
|
||||
WAITFORIT_result=$?
|
||||
fi
|
||||
if [[ $WAITFORIT_result -eq 0 ]]; then
|
||||
WAITFORIT_end_ts=$(date +%s)
|
||||
echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds"
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
return $WAITFORIT_result
|
||||
}
|
||||
|
||||
wait_for_wrapper()
|
||||
{
|
||||
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
|
||||
if [[ $WAITFORIT_QUIET -eq 1 ]]; then
|
||||
timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
|
||||
else
|
||||
timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
|
||||
fi
|
||||
WAITFORIT_PID=$!
|
||||
trap "kill -INT -$WAITFORIT_PID" INT
|
||||
wait $WAITFORIT_PID
|
||||
WAITFORIT_RESULT=$?
|
||||
if [[ $WAITFORIT_RESULT -ne 0 ]]; then
|
||||
echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
|
||||
fi
|
||||
return $WAITFORIT_RESULT
|
||||
}
|
||||
|
||||
# process arguments
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case "$1" in
|
||||
*:* )
|
||||
WAITFORIT_hostport=(${1//:/ })
|
||||
WAITFORIT_HOST=${WAITFORIT_hostport[0]}
|
||||
WAITFORIT_PORT=${WAITFORIT_hostport[1]}
|
||||
shift 1
|
||||
;;
|
||||
--child)
|
||||
WAITFORIT_CHILD=1
|
||||
shift 1
|
||||
;;
|
||||
-q | --quiet)
|
||||
WAITFORIT_QUIET=1
|
||||
shift 1
|
||||
;;
|
||||
-s | --strict)
|
||||
WAITFORIT_STRICT=1
|
||||
shift 1
|
||||
;;
|
||||
-h)
|
||||
WAITFORIT_HOST="$2"
|
||||
if [[ $WAITFORIT_HOST == "" ]]; then break; fi
|
||||
shift 2
|
||||
;;
|
||||
--host=*)
|
||||
WAITFORIT_HOST="${1#*=}"
|
||||
shift 1
|
||||
;;
|
||||
-p)
|
||||
WAITFORIT_PORT="$2"
|
||||
if [[ $WAITFORIT_PORT == "" ]]; then break; fi
|
||||
shift 2
|
||||
;;
|
||||
--port=*)
|
||||
WAITFORIT_PORT="${1#*=}"
|
||||
shift 1
|
||||
;;
|
||||
-t)
|
||||
WAITFORIT_TIMEOUT="$2"
|
||||
if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi
|
||||
shift 2
|
||||
;;
|
||||
--timeout=*)
|
||||
WAITFORIT_TIMEOUT="${1#*=}"
|
||||
shift 1
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
WAITFORIT_CLI=("$@")
|
||||
break
|
||||
;;
|
||||
--help)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
echoerr "Unknown argument: $1"
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then
|
||||
echoerr "Error: you need to provide a host and port to test."
|
||||
usage
|
||||
fi
|
||||
|
||||
WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15}
|
||||
WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
|
||||
WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
|
||||
WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}
|
||||
|
||||
# Check to see if timeout is from busybox?
|
||||
WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
|
||||
WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
|
||||
|
||||
WAITFORIT_BUSYTIMEFLAG=""
|
||||
if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
|
||||
WAITFORIT_ISBUSY=1
|
||||
# Check if busybox timeout uses -t flag
|
||||
# (recent Alpine versions don't support -t anymore)
|
||||
if timeout &>/dev/stdout | grep -q -e '-t '; then
|
||||
WAITFORIT_BUSYTIMEFLAG="-t"
|
||||
fi
|
||||
else
|
||||
WAITFORIT_ISBUSY=0
|
||||
fi
|
||||
|
||||
if [[ $WAITFORIT_CHILD -gt 0 ]]; then
|
||||
wait_for
|
||||
WAITFORIT_RESULT=$?
|
||||
exit $WAITFORIT_RESULT
|
||||
else
|
||||
if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
|
||||
wait_for_wrapper
|
||||
WAITFORIT_RESULT=$?
|
||||
else
|
||||
wait_for
|
||||
WAITFORIT_RESULT=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $WAITFORIT_CLI != "" ]]; then
|
||||
if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then
|
||||
echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess"
|
||||
exit $WAITFORIT_RESULT
|
||||
fi
|
||||
exec "${WAITFORIT_CLI[@]}"
|
||||
else
|
||||
exit $WAITFORIT_RESULT
|
||||
fi
|
@ -60,6 +60,8 @@ services:
|
||||
|
||||
contract-migration:
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-internal-integration/contract-migration:${TAG:-latest}
|
||||
ports:
|
||||
- 8012:8000
|
||||
build:
|
||||
context: apps/contract-migration
|
||||
dockerfile: docker/Dockerfile
|
||||
@ -68,7 +70,6 @@ services:
|
||||
pip_extra_args: $PIP_EXTRA_ARGS
|
||||
EXTRA_INDEX_URL: ${EXTRA_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
|
||||
EXTRA_PIP_ARGS: $EXTRA_PIP_ARGS
|
||||
# image: registry.gitlab.com/grassrootseconomics/cic-internal-integration/contract-migration:latest
|
||||
environment:
|
||||
RPC_PROVIDER: ${RPC_PROVIDER:-http://eth:8545}
|
||||
ETH_PROVIDER: ${RPC_PROVIDER:-http://eth:8545}
|
||||
@ -93,9 +94,14 @@ services:
|
||||
RUN_MASK: ${RUN_MASK:-0} # bit flags; 1: contract migrations 2: seed data
|
||||
DEV_FAUCET_AMOUNT: ${DEV_FAUCET_AMOUNT:-50000000}
|
||||
DEV_ETH_GAS_PRICE: $DEV_ETH_GAS_PRICE
|
||||
#DEV_GAS_AMOUNT: "100000000000000000000000" # removed from env_reset
|
||||
#WALLET_KEY_FILE: ./keystore/UTC--2021-01-08T17-18-44.521011372Z--eb3907ecad74a0013c259d5874ae7f22dcbcc95c #removed from env_reset
|
||||
TOKEN_NAME: ${TOKEN_NAME:-Giftable Token}
|
||||
TOKEN_SYMBOL: ${TOKEN_SYMBOL:-GFT}
|
||||
TOKEN_TYPE: ${TOKEN_TYPE:-giftable_erc20_token}
|
||||
#TOKEN_NAME: ${TOKEN_NAME:-Demurrage Token}
|
||||
#TOKEN_SYMBOL: ${TOKEN_SYMBOL:-DET}
|
||||
#TOKEN_TYPE: ${TOKEN_TYPE:-erc20_demurrage_token }
|
||||
TOKEN_DECIMALS: $TOKEN_DECIMALS
|
||||
TOKEN_REDISTRIBUTION_PERIOD: $TOKEN_DEMURRAGE_REDISTRIBUTION_PERIOD
|
||||
TASKS_TRANSFER_CALLBACKS: ${TASKS_TRANSFER_CALLBACKS:-"cic-eth:cic_eth.callbacks.noop.noop,cic-ussd:cic_ussd.tasks.callback_handler.transaction_callback"}
|
||||
@ -103,9 +109,8 @@ services:
|
||||
TOKEN_DEMURRAGE_LEVEL: $TOKEN_DEMURRAGE_LEVEL
|
||||
TOKEN_SINK_ADDRESS: $TOKEN_SINK_ADDRESS
|
||||
SIGNER_PROVIDER: ${SIGNER_SOCKET_PATH:-http://cic-eth-signer:8000}
|
||||
restart: on-failure
|
||||
command: ["./run_job.sh"]
|
||||
#command: ["./reset.sh"]
|
||||
#command: bash -c "while true; do sleep 1; done" # Infinite loop to keep container live doing nothing
|
||||
depends_on:
|
||||
- eth
|
||||
- postgres
|
||||
@ -113,7 +118,7 @@ services:
|
||||
- cic-eth-tasker
|
||||
volumes:
|
||||
- contract-config:/tmp/cic/config
|
||||
|
||||
- ./apps/contract-migration:/root
|
||||
|
||||
data-seeding:
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-internal-integration/data-seeding:${TAG:-latest}
|
||||
@ -153,9 +158,11 @@ services:
|
||||
USSD_PROVIDER: http://cic-user-ussd-server:9000
|
||||
CELERY_QUEUE: cic-import-ussd
|
||||
EXCLUSIONS: ussd
|
||||
command: bash import_ussd.sh
|
||||
CONTRACT_MIGRATION_URL: contract-migration:8000
|
||||
command: bash ./scripts/run_job.sh
|
||||
volumes:
|
||||
- contract-config:/tmp/cic/config/:ro
|
||||
#- ./apps/data-seeding:/root
|
||||
|
||||
cic-cache-tracker:
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-internal-integration/cic-cache:${TAG:-latest}
|
||||
@ -181,17 +188,13 @@ services:
|
||||
CIC_CHAIN_SPEC: ${CHAIN_SPEC:-evm:bloxberg:8996}
|
||||
CELERY_BROKER_URL: redis://redis:6379
|
||||
CELERY_RESULT_URL: redis://redis:6379
|
||||
CONTRACT_MIGRATION_URL: contract-migration:8000
|
||||
restart: on-failure
|
||||
depends_on:
|
||||
- redis
|
||||
- postgres
|
||||
- eth
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
- |
|
||||
if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi
|
||||
./start_tracker.sh -c /usr/local/etc/cic-cache -vv
|
||||
command: ./start_tracker.sh -c /usr/local/etc/cic-cache -vv
|
||||
volumes:
|
||||
- contract-config:/tmp/cic/config/:ro
|
||||
|
||||
@ -218,17 +221,13 @@ services:
|
||||
CIC_CHAIN_SPEC: ${CIC_CHAIN_SPEC:-evm:bloxberg:8996}
|
||||
CELERY_BROKER_URL: redis://redis:6379
|
||||
CELERY_RESULT_URL: redis://redis:6379
|
||||
CONTRACT_MIGRATION_URL: contract-migration:8000
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- redis
|
||||
- postgres
|
||||
- eth
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
- |
|
||||
if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi
|
||||
/usr/local/bin/cic-cache-taskerd -vv
|
||||
command: bash docker/start_tasker.sh
|
||||
volumes:
|
||||
- contract-config:/tmp/cic/config/:ro
|
||||
|
||||
@ -243,10 +242,10 @@ services:
|
||||
DATABASE_USER: ${DATABASE_USER:-grassroots}
|
||||
DATABASE_HOST: ${DATABASE_HOST:-postgres}
|
||||
DATABASE_PORT: ${DATABASE_PORT:-5432}
|
||||
#DATABASE_PASSWORD: ${DATABASE_PASSWORD:-
|
||||
DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala}
|
||||
DATABASE_NAME: ${DATABASE_NAME_CIC_CACHE:-cic_cache}
|
||||
DATABASE_DEBUG: 1
|
||||
#PGPASSWORD: $DATABASE_PASSWORD
|
||||
CONTRACT_MIGRATION_URL: contract-migration:8000
|
||||
SERVER_PORT: 8000
|
||||
restart: on-failure
|
||||
ports:
|
||||
@ -255,16 +254,7 @@ services:
|
||||
- postgres
|
||||
- cic-cache-tasker
|
||||
- cic-cache-tracker
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
- |
|
||||
if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi
|
||||
"/usr/local/bin/uwsgi" \
|
||||
--wsgi-file /root/cic_cache/runnable/daemons/server.py \
|
||||
--http :8000 \
|
||||
--pyargv "-vv"
|
||||
|
||||
command: bash docker/start_server.sh
|
||||
|
||||
cic-eth-tasker:
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-internal-integration/cic-eth:${TAG:-latest}
|
||||
@ -302,6 +292,7 @@ services:
|
||||
ETH_ACCOUNT_ACCOUNTS_INDEX_WRITER: ${DEV_ETH_ACCOUNT_ACCOUNTS_INDEX_WRITER:-0xACB0BC74E1686D62dE7DC6414C999EA60C09F0eA}
|
||||
TASKS_TRACE_QUEUE_STATUS: ${TASKS_TRACE_QUEUE_STATUS:-1}
|
||||
CIC_DEFAULT_TOKEN_SYMBOL: ${CIC_DEFAULT_TOKEN_SYMBOL:-GFT}
|
||||
CONTRACT_MIGRATION_URL: contract-migration:8000
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- eth
|
||||
@ -313,12 +304,7 @@ services:
|
||||
- contract-config:/tmp/cic/config/:ro
|
||||
#command: ["/usr/local/bin/cic-eth-taskerd"]
|
||||
#command: ["sleep", "3600"]
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
- |
|
||||
if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi
|
||||
./start_tasker.sh --aux-all -q cic-eth -vv
|
||||
command: ./start_tasker.sh --aux-all -q cic-eth -vv
|
||||
|
||||
cic-eth-signer:
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-internal-integration/cic-eth:${TAG:-latest}
|
||||
@ -365,13 +351,6 @@ services:
|
||||
- signer-data:/run/crypto-dev-signer
|
||||
- contract-config:/tmp/cic/config/:ro
|
||||
command: ["python", "/usr/local/bin/crypto-dev-daemon", "-c", "/usr/local/etc/crypto-dev-signer", "-vv"]
|
||||
#command:
|
||||
# - /bin/bash
|
||||
# - -c
|
||||
# - |
|
||||
# if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi
|
||||
# ./start_tasker.sh --aux-all -q cic-eth -vv
|
||||
# command: [/bin/sh, "./start_tasker.sh", -q, cic-eth, -vv ]
|
||||
|
||||
cic-eth-tracker:
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-internal-integration/cic-eth:${TAG:-latest}
|
||||
@ -384,6 +363,7 @@ services:
|
||||
environment:
|
||||
RPC_PROVIDER: ${RPC_PROVIDER:-http://eth:8545}
|
||||
ETH_PROVIDER: ${RPC_PROVIDER:-http://eth:8545}
|
||||
RPC_HTTP_PROVIDER: ${RPC_PROVIDER:-http://eth:8545}
|
||||
DATABASE_USER: ${DATABASE_USER:-grassroots}
|
||||
DATABASE_HOST: ${DATABASE_HOST:-postgres}
|
||||
DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala}
|
||||
@ -398,6 +378,7 @@ services:
|
||||
CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis}
|
||||
CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis}
|
||||
TASKS_TRANSFER_CALLBACKS: ${TASKS_TRANSFER_CALLBACKS:-"cic-eth:cic_eth.callbacks.noop.noop,cic-ussd:cic_ussd.tasks.callback_handler.transaction_callback"}
|
||||
CONTRACT_MIGRATION_URL: contract-migration:8000
|
||||
restart: on-failure
|
||||
depends_on:
|
||||
- eth
|
||||
@ -405,15 +386,7 @@ services:
|
||||
- redis
|
||||
volumes:
|
||||
- contract-config:/tmp/cic/config/:ro
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
- |
|
||||
if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi
|
||||
#./start_tracker.sh -vv -c /usr/local/etc/cic-eth
|
||||
./start_tracker.sh -vv
|
||||
# command: "/root/start_manager.sh head -vv"
|
||||
|
||||
command: bash ./start_tracker.sh -vv
|
||||
|
||||
cic-eth-dispatcher:
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-internal-integration/cic-eth:${TAG:-latest}
|
||||
@ -436,12 +409,12 @@ services:
|
||||
CIC_CHAIN_SPEC: ${CIC_CHAIN_SPEC:-evm:bloxberg:8996}
|
||||
CHAIN_SPEC: ${CIC_CHAIN_SPEC:-evm:bloxberg:8996}
|
||||
CIC_REGISTRY_ADDRESS: $CIC_REGISTRY_ADDRESS
|
||||
#BANCOR_DIR: $BANCOR_DIR
|
||||
CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis}
|
||||
CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis}
|
||||
TASKS_TRANSFER_CALLBACKS: $TASKS_TRANSFER_CALLBACKS
|
||||
DATABASE_DEBUG: ${DATABASE_DEBUG:-false}
|
||||
#DATABASE_DEBUG: 1
|
||||
CONTRACT_MIGRATION_URL: contract-migration:8000
|
||||
restart: on-failure
|
||||
depends_on:
|
||||
- eth
|
||||
@ -449,13 +422,7 @@ services:
|
||||
- redis
|
||||
volumes:
|
||||
- contract-config:/tmp/cic/config/:ro
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
- |
|
||||
if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi
|
||||
./start_dispatcher.sh -q cic-eth -vv
|
||||
# command: "/root/start_dispatcher.sh -q cic-eth -vv"
|
||||
command: bash start_dispatcher.sh -q cic-eth -vv
|
||||
|
||||
|
||||
|
||||
@ -488,6 +455,7 @@ services:
|
||||
CIC_TX_RETRY_DELAY: 60
|
||||
BATCH_SIZE: ${RETRIER_BATCH_SIZE:-50}
|
||||
#DATABASE_DEBUG: 1
|
||||
CONTRACT_MIGRATION_URL: contract-migration:8000
|
||||
restart: on-failure
|
||||
depends_on:
|
||||
- eth
|
||||
@ -495,15 +463,7 @@ services:
|
||||
- redis
|
||||
volumes:
|
||||
- contract-config:/tmp/cic/config/:ro
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
- |
|
||||
if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi
|
||||
./start_retry.sh -vv
|
||||
# command: "/root/start_retry.sh -q cic-eth -vv"
|
||||
|
||||
|
||||
command: bash start_retry.sh -vv
|
||||
|
||||
cic-notify-tasker:
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-internal-integration/cic-notify:${TAG:-latest}
|
||||
|
@ -1 +1 @@
|
||||
docker run -t -v --rm cic-internal-integration_contract-config:/tmp/cic/config busybox cat /tmp/cic/config/env_reset
|
||||
docker run --rm -v cic-internal-integration_contract-config:/tmp/cic/config busybox cat /tmp/cic/config/env_reset
|
||||
|
Loading…
Reference in New Issue
Block a user