Added a test_setup command.
This commit is contained in:
@@ -683,6 +683,38 @@ stop() {
|
||||
fi
|
||||
}
|
||||
|
||||
test_setup(){
|
||||
# Check if the container exists (running or stopped)
|
||||
if docker ps -a --format '{{.Names}}' | grep -q "^$CONTAINER_NAME$"; then
|
||||
# Check if the container is running
|
||||
if docker ps --format '{{.Names}}' | grep -q "^$CONTAINER_NAME$"; then
|
||||
# Stop the container
|
||||
RESPONSE=$(wget -qO- "http://127.0.0.1:$API_PORT/ping" 2>/dev/null)
|
||||
|
||||
if [ "$RESPONSE" = '"Ok"' ]; then
|
||||
print_header "Container '$CONTAINER_NAME' is Found.
|
||||
Container '$CONTAINER_NAME' is running.
|
||||
App returned Ok to ping request."
|
||||
return 0
|
||||
else
|
||||
print_header "Container Found.
|
||||
Container Running.
|
||||
Error with the return of the App, it is not working right.
|
||||
Response: $RESPONSE"
|
||||
return 1
|
||||
fi
|
||||
|
||||
else
|
||||
print_header "Container '$CONTAINER_NAME' is Found.
|
||||
Container '$CONTAINER_NAME' is not running."
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
print_header "Container '$CONTAINER_NAME' does not exist."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
help() {
|
||||
print_header "help:
|
||||
|
||||
@@ -694,6 +726,7 @@ Source Code Management:
|
||||
|
||||
App Running:
|
||||
> status
|
||||
> test_setup
|
||||
> start
|
||||
> restart
|
||||
> stop
|
||||
@@ -735,6 +768,7 @@ main() {
|
||||
stop) stop ;;
|
||||
show_config) show_config ;;
|
||||
update_config) update_config ;;
|
||||
test_setup) test_setup ;;
|
||||
help) help ;;
|
||||
*) echo "Invalid argument: $1"; help ;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user