##// END OF EJS Templates
feat(rcstack): added doctor commands to check system health
super-admin -
Show More
@@ -845,6 +845,7 b' rcstack_cli_usage() {'
845 echo
845 echo
846 printf "%s\n" "System health checks Commands:"
846 printf "%s\n" "System health checks Commands:"
847 printf " %s runs a traffic test against the current rhodecode instance\n" "test-traffic "
847 printf " %s runs a traffic test against the current rhodecode instance\n" "test-traffic "
848 printf " %s runs a test for stack health\n" "test-doctor "
848 echo
849 echo
849
850
850 # :command.long_usage
851 # :command.long_usage
@@ -1070,6 +1071,33 b' rcstack_cli_test_traffic_usage() {'
1070 }
1071 }
1071
1072
1072 # :command.usage
1073 # :command.usage
1074 rcstack_cli_test_doctor_usage() {
1075 printf "rcstack cli test-doctor - runs a test for stack health\n\n"
1076
1077 printf "%s\n" "Usage:"
1078 printf " rcstack cli test-doctor [OPTIONS]\n"
1079 printf " rcstack cli test-doctor --help | -h\n"
1080 echo
1081
1082 # :command.long_usage
1083 if [[ -n "$long_usage" ]]; then
1084 printf "%s\n" "Options:"
1085
1086 # :command.usage_flags
1087 # :flag.usage
1088 printf " %s\n" "--verbose"
1089 printf " rich output about image\n"
1090 echo
1091
1092 # :command.usage_fixed_flags
1093 printf " %s\n" "--help, -h"
1094 printf " Show this help\n"
1095 echo
1096
1097 fi
1098 }
1099
1100 # :command.usage
1073 deprecated_cli_set_runtime_image_usage() {
1101 deprecated_cli_set_runtime_image_usage() {
1074 printf "rcstack cli set-runtime-image - DEPRECATED - use 'set-image' instead\n\n"
1102 printf "rcstack cli set-runtime-image - DEPRECATED - use 'set-image' instead\n\n"
1075
1103
@@ -4357,11 +4385,6 b' rcstack_cli_set_image_command() {'
4357 # :command.function
4385 # :command.function
4358 rcstack_cli_test_traffic_command() {
4386 rcstack_cli_test_traffic_command() {
4359 # src/cli_test_traffic_command.sh
4387 # src/cli_test_traffic_command.sh
4360 echo "# this file is located in 'src/cli_test_traffic_command.sh'"
4361 echo "# code for 'rcstack cli test-traffic' goes here"
4362 echo "# you can edit it freely and regenerate (it will not be overwritten)"
4363 inspect_args
4364
4365 test_url=${args[--test-url]}
4388 test_url=${args[--test-url]}
4366
4389
4367 .env --file $RUNTIME_ENV
4390 .env --file $RUNTIME_ENV
@@ -4372,6 +4395,26 b' rcstack_cli_test_traffic_command() {'
4372 echo "$(green "Testing traffic from Host: $HOSTNAME to $test_url")"
4395 echo "$(green "Testing traffic from Host: $HOSTNAME to $test_url")"
4373 curl -v -L --fail --header "Host: $HOSTNAME" $test_url
4396 curl -v -L --fail --header "Host: $HOSTNAME" $test_url
4374 echo ""
4397 echo ""
4398
4399 }
4400
4401 # :command.function
4402 rcstack_cli_test_doctor_command() {
4403 # src/cli_test_doctor_command.sh
4404
4405 echo "Doctor $(green_bold [1]): checking for unhealthy containers..."
4406
4407 if ./rcstack status | grep --ignore-case -q "unhealthy"; then
4408 echo "Doctor $(red_bold ERROR): unhealthy containers found"
4409 ./rcstack status
4410 exit 1
4411 elif ./rcstack status | grep --ignore-case -q "restarting"; then
4412 echo "Doctor $(red_bold ERROR): restarting containers found"
4413 ./rcstack status
4414 exit 1
4415 else
4416 echo "Doctor $(green_bold OK): no unhealthy or restarting containers found"
4417 fi
4375 }
4418 }
4376
4419
4377 # :command.function
4420 # :command.function
@@ -6807,6 +6850,13 b' rcstack_cli_parse_requirements() {'
6807 shift $#
6850 shift $#
6808 ;;
6851 ;;
6809
6852
6853 test-doctor)
6854 action="test-doctor"
6855 shift
6856 rcstack_cli_test_doctor_parse_requirements "$@"
6857 shift $#
6858 ;;
6859
6810 set-runtime-image)
6860 set-runtime-image)
6811 action="set-runtime-image"
6861 action="set-runtime-image"
6812 shift
6862 shift
@@ -7359,6 +7409,57 b' rcstack_cli_test_traffic_parse_requirements() {'
7359 }
7409 }
7360
7410
7361 # :command.parse_requirements
7411 # :command.parse_requirements
7412 rcstack_cli_test_doctor_parse_requirements() {
7413 # :command.fixed_flags_filter
7414 while [[ $# -gt 0 ]]; do
7415 case "${1:-}" in
7416 --help | -h)
7417 long_usage=yes
7418 rcstack_cli_test_doctor_usage
7419 exit
7420 ;;
7421
7422 *)
7423 break
7424 ;;
7425
7426 esac
7427 done
7428
7429 # :command.command_filter
7430 action="cli test-doctor"
7431
7432 # :command.parse_requirements_while
7433 while [[ $# -gt 0 ]]; do
7434 key="$1"
7435 case "$key" in
7436 # :flag.case
7437 --verbose)
7438
7439 # :flag.case_no_arg
7440 args['--verbose']=1
7441 shift
7442 ;;
7443
7444 -?*)
7445 printf "invalid option: %s\n" "$key" >&2
7446 exit 1
7447 ;;
7448
7449 *)
7450 # :command.parse_requirements_case
7451 # :command.parse_requirements_case_simple
7452 printf "invalid argument: %s\n" "$key" >&2
7453 exit 1
7454
7455 ;;
7456
7457 esac
7458 done
7459
7460 }
7461
7462 # :command.parse_requirements
7362 deprecated_cli_set_runtime_image_parse_requirements() {
7463 deprecated_cli_set_runtime_image_parse_requirements() {
7363 # :command.fixed_flags_filter
7464 # :command.fixed_flags_filter
7364 while [[ $# -gt 0 ]]; do
7465 while [[ $# -gt 0 ]]; do
@@ -8539,6 +8640,7 b' run() {'
8539 "cli image-list") rcstack_cli_image_list_command ;;
8640 "cli image-list") rcstack_cli_image_list_command ;;
8540 "cli set-image") rcstack_cli_set_image_command ;;
8641 "cli set-image") rcstack_cli_set_image_command ;;
8541 "cli test-traffic") rcstack_cli_test_traffic_command ;;
8642 "cli test-traffic") rcstack_cli_test_traffic_command ;;
8643 "cli test-doctor") rcstack_cli_test_doctor_command ;;
8542 "cli set-runtime-image") deprecated_cli_set_runtime_image_command ;;
8644 "cli set-runtime-image") deprecated_cli_set_runtime_image_command ;;
8543 "cli set-edition") rcstack_cli_set_edition_command ;;
8645 "cli set-edition") rcstack_cli_set_edition_command ;;
8544 "cli set-hostname") rcstack_cli_set_hostname_command ;;
8646 "cli set-hostname") rcstack_cli_set_hostname_command ;;
General Comments 0
You need to be logged in to leave comments. Login now