@@ -124,8 +124,16 @@ insert_keys() {
124124
125125# Function to set up and start node service
126126setup_node_service () {
127- echo " setup_node_service"
128- sudo bash -c ' cat > /etc/systemd/system/sugarfunge-node.service' << EOF
127+ node_service_file_path=" /etc/systemd/system/sugarfunge-node.service"
128+ echo " setup_node_service at $node_service_file_path "
129+ # Check if the file exists and then remove it
130+ if [ -f " $node_service_file_path " ]; then
131+ sudo rm " $node_service_file_path "
132+ echo " Removed $node_service_file_path ."
133+ else
134+ echo " $node_service_file_path does not exist."
135+ fi
136+ sudo bash -c ' cat > $node_service_file_path' << EOF
129137[Unit]
130138Description=Sugarfunge Node
131139After=network.target
@@ -143,11 +151,14 @@ ExecStart=$HOME/sugarfunge-node/target/release/sugarfunge-node \
143151 --rpc-cors=all \
144152 --rpc-methods=Unsafe \
145153 --rpc-external \
146- --validator \
147154 --name MyNode \
148155 --password-filename="$PASSWORD_FILE " \
149- --node-key=$( cat " $SECRET_DIR /node_key.txt" )
156+ --node-key=$( cat " $SECRET_DIR /node_key.txt" ) \
157+ --bootnodes /dns4/node.functionyard.fula.network/tcp/30334/p2p/12D3KooWBeXV65svCyknCvG1yLxXVFwRxzBLqvBJnUF6W84BLugv
150158Restart=always
159+ RestartSec=10s
160+ StartLimitInterval=5min
161+ StartLimitBurst=4
151162StandardOutput=file:"$LOG_DIR /MyNode.log"
152163StandardError=file:"$LOG_DIR /MyNode.err"
153164
163174
164175# Function to set up and start API service
165176setup_api_service () {
166- echo " setup_api_service"
167- sudo bash -c ' cat > /etc/systemd/system/sugarfunge-api.service' << EOF
177+ api_service_file_path=" /etc/systemd/system/sugarfunge-api.service"
178+ echo " setup_api_service at $api_service_file_path "
179+ # Check if the file exists and then remove it
180+ if [ -f " $api_service_file_path " ]; then
181+ sudo rm " $api_service_file_path "
182+ echo " Removed $api_service_file_path ."
183+ else
184+ echo " $api_service_file_path does not exist."
185+ fi
186+ sudo bash -c ' cat > $api_service_file_path' << EOF
168187[Unit]
169188Description=Sugarfunge API
170189After=sugarfunge-node.service
@@ -175,7 +194,7 @@ Type=simple
175194User=$USER
176195ExecStart=$HOME /sugarfunge-api/target/release/sugarfunge-api \
177196 --db-uri="$DATA_DIR " \
178- --node-server ws://127.0.0.1:9946
197+ --node-server ws://127.0.0.1:9944
179198Environment=FULA_SUGARFUNGE_API_HOST=http://127.0.0.1:4000 \
180199 FULA_CONTRACT_API_HOST=https://contract-api.functionyard.fula.network \
181200 LABOR_TOKEN_CLASS_ID=100 \
@@ -187,6 +206,9 @@ Environment=FULA_SUGARFUNGE_API_HOST=http://127.0.0.1:4000 \
187206 CLAIMED_TOKEN_CLASS_ID=120 \
188207 CLAIMED_TOKEN_ASSET_ID=100
189208Restart=always
209+ RestartSec=10s
210+ StartLimitInterval=5min
211+ StartLimitBurst=4
190212StandardOutput=file:"$LOG_DIR /MyNodeAPI.log"
191213StandardError=file:"$LOG_DIR /MyNodeAPI.err"
192214
202224
203225# Function to set up and start go-fula service
204226setup_gofula_service () {
205- echo " setup_gofula_service"
206- sudo bash -c ' cat > /etc/systemd/system/go-fula.service' << EOF
227+ gofula_service_file_path=" /etc/systemd/system/go-fula.service"
228+ echo " setup go-fula service at $gofula_service_file_path "
229+ # Check if the file exists and then remove it
230+ if [ -f " $gofula_service_file_path " ]; then
231+ sudo rm " $gofula_service_file_path "
232+ echo " Removed $gofula_service_file_path ."
233+ else
234+ echo " $gofula_service_file_path does not exist."
235+ fi
236+ sudo bash -c ' cat > $gofula_service_file_path' << EOF
207237[Unit]
208238Description=Go Fula Service
209239After=network.target
@@ -212,6 +242,9 @@ After=network.target
212242Type=simple
213243ExecStart=/home/$USER /go-fula/go-fula
214244Restart=always
245+ RestartSec=10s
246+ StartLimitInterval=5min
247+ StartLimitBurst=4
215248
216249[Install]
217250WantedBy=multi-user.target
@@ -312,8 +345,10 @@ main() {
312345 fi
313346
314347 region=$1
315- pool_name=" ${region// / } "
316-
348+ pool_name=$( echo " $region " | sed -e ' s/\([A-Z]\)/ \1/g' -e ' s/^ //' )
349+
350+ echo " creating region=$region and pool_name=$pool_name "
351+
317352 # Update and install dependencies
318353 sudo apt update
319354 sudo apt install -y wget git curl build-essential jq pkg-config libssl-dev protobuf-compiler llvm libclang-dev clang plocate cmake
@@ -341,21 +376,21 @@ main() {
341376 # Insert keys into the node
342377 insert_keys
343378
344- # Setup and start node service
345- setup_node_service
346-
347- # Setup and start API service
348- setup_api_service
349-
350- # Setup and start go-fula service
351- setup_gofula_service
352-
353379 # Fund an account
354380 fund_account
355381
356382 # Create a pool
357383 create_pool " $pool_name " " $region "
358384
385+ # Setup and start node service
386+ setup_node_service
387+
388+ # Setup and start API service
389+ setup_api_service
390+
391+ # Setup and start go-fula service
392+ setup_gofula_service
393+
359394 cleanup
360395
361396 unset MASTER_SEED
0 commit comments