-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart.sh
executable file
·150 lines (125 loc) · 5.76 KB
/
start.sh
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
. ./bash_functions.sh
# Script to start all Gateway services on the Frequency Paseo Testnet
# Check for Docker and Docker Compose
if ! command -v docker &> /dev/null || ! command -v docker compose &> /dev/null; then
${OUTPUT} "Docker and Docker Compose are required but not installed. Please install them and try again.\n"
exit 1
fi
BASE_DIR=./
ENV_FILE=${BASE_DIR}/.env-saved
COMPOSE_PROJECT_NAME=${BASE_NAME}
if [[ -n $ENV_FILE ]]; then
${OUTPUT} "Using environment file: $ENV_FILE\n"
fi
# Load existing .env-saved file if it exists
if [ -f .env-saved ]; then
${OUTPUT} "Found saved environment from a previous run:\n"
redact_sensitive_values .env-saved
echo
read -p "Do you want to re-use the saved parameters? [Y/n]: " REUSE_SAVED
REUSE_SAVED=${REUSE_SAVED:-y}
if [[ ${REUSE_SAVED} =~ ^[Yy] ]]; then
${OUTPUT} 'Loading existing .env-saved file environment values...'
else
${OUTPUT} 'Removing previous saved environment...'
rm .env-saved
fi
fi
if [ ! -f .env-saved ]; then
# Setup some variables for easy port management
STARTING_PORT=3010
for i in {0..10}
do
eval SERVICE_PORT_${i}=$(( STARTING_PORT + i ))
export_save_variable SERVICE_PORT_${i} $(( STARTING_PORT + i ))
done
# Create .env-saved file to store environment variables
${OUTPUT} 'Creating .env-saved file to store environment variables... '
echo "COMPOSE_PROJECT_NAME='gateway-dev'" >> .env-saved
# Ask the user if they want to start on testnet or local
read -p "Do you want to start on Frequency Paseo Testnet [y/N]: " TESTNET_ENV
export_save_variable TESTNET_ENV ${TESTNET_ENV}
if [[ $TESTNET_ENV =~ ^[Yy]$ ]]; then
${OUTPUT} << EOI
Setting defaults for testnet...
Hit <ENTER> to accept the default value, or,
enter new value and then hit <ENTER>"
EOI
DEFAULT_TESTNET_ENV="testnet"
DEFAULT_FREQUENCY_API_WS_URL="wss://0.rpc.testnet.amplica.io"
DEFAULT_SIWF_NODE_RPC_URL="https://0.rpc.testnet.amplica.io"
DEFAULT_PROVIDER_ID="INPUT REQUIRED"
DEFAULT_PROVIDER_ACCOUNT_SEED_PHRASE="INPUT REQUIRED"
else
echo -e "\nStarting on local..."
DEFAULT_TESTNET_ENV="local"
DEFAULT_FREQUENCY_API_WS_URL="ws://frequency:9944"
DEFAULT_SIWF_NODE_RPC_URL="http://localhost:9944"
DEFAULT_PROVIDER_ID="1"
DEFAULT_PROVIDER_ACCOUNT_SEED_PHRASE="//Alice"
fi
DEFAULT_IPFS_VOLUME="/data/ipfs"
DEFAULT_IPFS_ENDPOINT="http://ipfs:5001"
DEFAULT_IPFS_GATEWAY_URL='https://ipfs.io/ipfs/[CID]'
DEFAULT_IPFS_BASIC_AUTH_USER=""
DEFAULT_IPFS_BASIC_AUTH_SECRET=""
DEFAULT_IPFS_UA_GATEWAY_URL="http://localhost:8080"
DEFAULT_CONTENT_DB_VOLUME="content_db"
ask_and_save FREQUENCY_API_WS_URL "Enter the Frequency API Websocket URL" "$DEFAULT_FREQUENCY_API_WS_URL"
ask_and_save SIWF_NODE_RPC_URL "Enter the SIWF Node RPC URL" "$DEFAULT_SIWF_NODE_RPC_URL"
box_text_attention -w ${BOX_WIDTH} << EOI
A Provider is required to start the services.
If you need to become a provider, visit
https://provider.frequency.xyz/ to get a Provider ID.
EOI
ask_and_save PROVIDER_ID "Enter Provider ID" "$DEFAULT_PROVIDER_ID"
ask_and_save PROVIDER_ACCOUNT_SEED_PHRASE "Enter Provider Seed Phrase" "$DEFAULT_PROVIDER_ACCOUNT_SEED_PHRASE"
${OUTPUT} "Suggestion: Change to an IPFS Pinning Service for better persistence and availability."
if yesno "===> Given this suggestion, would you like to change the IPFS settings?"; then
ask_and_save IPFS_VOLUME "Enter the IPFS volume" "$DEFAULT_IPFS_VOLUME"
ask_and_save IPFS_ENDPOINT "Enter the IPFS Endpoint" "$DEFAULT_IPFS_ENDPOINT"
ask_and_save IPFS_GATEWAY_URL "Enter the IPFS Gateway URL" "$DEFAULT_IPFS_GATEWAY_URL"
ask_and_save IPFS_BASIC_AUTH_USER "Enter the IPFS Basic Auth User" "$DEFAULT_IPFS_BASIC_AUTH_USER"
ask_and_save IPFS_BASIC_AUTH_SECRET "Enter the IPFS Basic Auth Secret" "$DEFAULT_IPFS_BASIC_AUTH_SECRET"
ask_and_save IPFS_UA_GATEWAY_URL "Enter the browser-resolveable IPFS Gateway URL" "$DEFAULT_IPFS_UA_GATEWAY_URL"
else
# Add the IPFS settings to the .env-saved file so defaults work with local testing
cat >> .env-saved << EOI
IPFS_VOLUME="${DEFAULT_IPFS_VOLUME}"
IPFS_ENDPOINT="${DEFAULT_IPFS_ENDPOINT}"
IPFS_GATEWAY_URL="${DEFAULT_IPFS_GATEWAY_URL}"
IPFS_BASIC_AUTH_USER="${DEFAULT_IPFS_BASIC_AUTH_USER}"
IPFS_BASIC_AUTH_SECRET="${DEFAULT_IPFS_BASIC_AUTH_SECRET}"
IPFS_UA_GATEWAY_URL="${DEFAULT_IPFS_UA_GATEWAY_URL}"
EOI
fi
fi
set -a; source .env-saved; set +a
if [[ ! $TESTNET_ENV =~ ^[Yy]$ ]]; then
# Start specific services in detached mode
echo -e "\nStarting local frequency services..."
docker compose up -d frequency
fi
# Start all services in detached mode
echo -e "\nStarting all services..."
docker compose --profile webhook --profile backend up -d
box_text_attention -w ${BOX_WIDTH} <<EOI
You can access the Gateway at the following local addresses:
* account-service:
- API: http://localhost:${SERVICE_PORT_3}
- Queue management: http://localhost:${SERVICE_PORT_3}/queues
- Swagger UI: http://localhost:${SERVICE_PORT_3}/docs/swagger
* content-publishing-service
- API: http://localhost:${SERVICE_PORT_0}
- Queue management: http://localhost:${SERVICE_PORT_0}/queues
- Swagger UI: http://localhost:${SERVICE_PORT_0}/docs/swagger
* content-watcher-service
- API: http://localhost:${SERVICE_PORT_1}
- Queue management: http://localhost:${SERVICE_PORT_1}/queues
- Swagger UI: http://localhost:${SERVICE_PORT_1}/docs/swagger
* graph-service
- API: http://localhost:${SERVICE_PORT_2}
- Queue management: http://localhost:${SERVICE_PORT_2}/queues
- Swagger UI: http://localhost:${SERVICE_PORT_2}/docs/swagger
EOI