@@ -39,6 +39,12 @@ start()
39
39
exit 1
40
40
fi
41
41
42
+ start_ipfs
43
+ if [ $? -ne 0 ]; then
44
+ docker-compose -f $builddir /docker-compose.yaml down
45
+ exit 1
46
+ fi
47
+
42
48
log_success " Start crust success"
43
49
}
44
50
47
53
stop_chain
48
54
stop_api
49
55
stop_sworker
56
+ stop_ipfs
50
57
51
58
log_success " Stop crust success"
52
59
}
@@ -75,6 +82,13 @@ logs()
75
82
return 0
76
83
fi
77
84
docker logs -f crust-sworker-$a_or_b
85
+ elif [ x" $1 " == x" ipfs" ]; then
86
+ check_docker_status ipfs
87
+ if [ $? -eq 1 ]; then
88
+ log_info " Service ipfs is not started now"
89
+ return 0
90
+ fi
91
+ docker logs -f ipfs
78
92
elif [ x" $1 " == x" sworker-a" ]; then
79
93
check_docker_status crust-sworker-a
80
94
if [ $? -eq 1 ]; then
@@ -235,6 +249,45 @@ stop_api()
235
249
fi
236
250
return 0
237
251
}
252
+
253
+ start_ipfs ()
254
+ {
255
+ if [ -d " $builddir /ipfs" ]; then
256
+ check_docker_status ipfs
257
+ if [ $? -ne 1 ]; then
258
+ return 0
259
+ fi
260
+
261
+ local res=0
262
+ check_port 4001
263
+ res=$(( $? | $res ))
264
+ check_port 5001
265
+ res=$(( $? | $res ))
266
+ check_port 37773
267
+ res=$(( $? | $res ))
268
+ if [ $res -ne 0 ]; then
269
+ return 1
270
+ fi
271
+
272
+ docker-compose -f $builddir /docker-compose.yaml up -d ipfs
273
+ if [ $? -ne 0 ]; then
274
+ log_err " [ERROR] Start ipfs failed"
275
+ return 1
276
+ fi
277
+ fi
278
+ return 0
279
+ }
280
+
281
+ stop_ipfs ()
282
+ {
283
+ check_docker_status ipfs
284
+ if [ $? -ne 1 ]; then
285
+ log_info " Stopping ipfs service"
286
+ docker stop ipfs & > /dev/null
287
+ docker rm ipfs & > /dev/null
288
+ fi
289
+ return 0
290
+ }
238
291
239
292
reload () {
240
293
if [ x" $1 " = x" " ]; then
@@ -290,6 +343,21 @@ reload() {
290
343
return 0
291
344
fi
292
345
346
+ if [ x" $1 " = x" ipfs" ]; then
347
+ log_info " Reload ipfs service"
348
+
349
+ stop_ipfs
350
+ $scriptdir /gen_config.sh
351
+ if [ $? -ne 0 ]; then
352
+ log_err " [ERROR] Generate configuration files failed"
353
+ exit 1
354
+ fi
355
+ start_ipfs
356
+
357
+ log_success " Reload ipfs service success"
358
+ return 0
359
+ fi
360
+
293
361
help
294
362
return 0
295
363
}
@@ -302,6 +370,8 @@ status()
302
370
api_status
303
371
elif [ x" $1 " == x" sworker" ]; then
304
372
sworker_status
373
+ elif [ x" $1 " == x" ipfs" ]; then
374
+ ipfs_status
305
375
elif [ x" $1 " == x" " ]; then
306
376
all_status
307
377
else
@@ -314,6 +384,7 @@ all_status()
314
384
local chain_status=" stop"
315
385
local api_status=" stop"
316
386
local sworker_status=" stop"
387
+ local ipfs_status=" stop"
317
388
318
389
check_docker_status crust
319
390
local res=$?
@@ -340,13 +411,22 @@ all_status()
340
411
sworker_status=" exited"
341
412
fi
342
413
414
+ check_docker_status ipfs
415
+ res=$?
416
+ if [ $res -eq 0 ]; then
417
+ ipfs_status=" running"
418
+ elif [ $res -eq 2 ]; then
419
+ ipfs_status=" exited"
420
+ fi
421
+
343
422
cat << EOF
344
423
-----------------------------------------
345
424
Service Status
346
425
-----------------------------------------
347
426
chain ${chain_status}
348
427
api ${api_status}
349
428
sworker ${sworker_status}
429
+ ipfs ${ipfs_status}
350
430
-----------------------------------------
351
431
EOF
352
432
}
@@ -433,6 +513,27 @@ cat << EOF
433
513
EOF
434
514
}
435
515
516
+ ipfs_status ()
517
+ {
518
+ local ipfs_status=" stop"
519
+
520
+ check_docker_status ipfs
521
+ res=$?
522
+ if [ $res -eq 0 ]; then
523
+ ipfs_status=" running"
524
+ elif [ $res -eq 2 ]; then
525
+ ipfs_status=" exited"
526
+ fi
527
+
528
+ cat << EOF
529
+ -----------------------------------------
530
+ Service Status
531
+ -----------------------------------------
532
+ ipfs ${ipfs_status}
533
+ -----------------------------------------
534
+ EOF
535
+ }
536
+
436
537
help ()
437
538
{
438
539
cat << EOF
@@ -441,9 +542,9 @@ Usage:
441
542
start start all crust service
442
543
stop stop all crust service
443
544
444
- status {chain|api|sworker} check status or reload one service status
445
- reload {chain|api|sworker} reload all service or reload one service
446
- logs {chain|api|sworker} track service logs, ctrl-c to exit
545
+ status {chain|api|sworker|ipfs} check status or reload one service status
546
+ reload {chain|api|sworker|ipfs} reload all service or reload one service
547
+ logs {chain|api|sworker|ipfs} track service logs, ctrl-c to exit
447
548
tools {...} use 'crust tools help' for more details
448
549
EOF
449
550
}
@@ -455,7 +556,7 @@ crust tools usage:
455
556
help show help information
456
557
rotate-keys generate session key of chain node
457
558
workload show workload information
458
- upgrade-reload {chain|api|c-gen} upgrade one docker image and reload the service
559
+ upgrade-reload {chain|api|ipfs| c-gen} upgrade one docker image and reload the service
459
560
change-srd {number} change sworker's srd capacity(GB), for example: 'crust tools change-srd 100', 'crust tools change-srd -50'
460
561
EOF
461
562
}
@@ -543,6 +644,12 @@ upgrade_reload()
543
644
return 1
544
645
fi
545
646
reload api
647
+ elif [ x" $1 " == x" ipfs" ]; then
648
+ upgrade_docker_image ipfs/go-ipfs crustio/go-ipfs
649
+ if [ $? -ne 0 ]; then
650
+ return 1
651
+ fi
652
+ reload api
546
653
elif [ x" $1 " == x" c-gen" ]; then
547
654
upgrade_docker_image crustio/config-generator
548
655
if [ $? -ne 0 ]; then
0 commit comments