forked from canton-network/splice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwait-for-canton.sh
More file actions
executable file
·54 lines (48 loc) · 1.42 KB
/
wait-for-canton.sh
File metadata and controls
executable file
·54 lines (48 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
# Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set -eou pipefail
function usage() {
echo "Usage: ./start-canton.sh <flags>"
echo "Flags:"
echo " -h display this help message"
echo " -w wait only for canton instance with wall clock time"
echo " -s wait only for canton instance with simulated time"
}
wallclocktime=1
simtime=1
while getopts "hws" arg; do
case ${arg} in
h)
usage
exit 0
;;
w)
simtime=0
echo "waiting only for canton with wall clock time"
;;
s)
wallclocktime=0
echo "waiting only for canton with simulated time"
;;
?)
;;
esac
done
# Wait for canton instance(s) to start within 5 minutes
timeout=300
start_time=$(date +%s)
while (( $(date +%s) - start_time < timeout )); do
if { [ $wallclocktime -eq 1 ] && [ ! -f canton.tokens ]; } || { [ $simtime -eq 1 ] && [ ! -f canton-simtime.tokens ]; }; then
remaining_time=$((timeout - ($(date +%s) - start_time)))
echo "Waiting for Canton instance(s) to start (${remaining_time} seconds left)"
sleep 1
else
echo "Canton instance(s) started"
break
fi
done
if (( $(date +%s) - start_time >= timeout )); then
echo "Timeout: Canton instance(s) failed to start within $timeout seconds"
exit 1
fi