mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-06-27 16:10:30 +08:00
chore: start-mock-server waits for health
This commit is contained in:
committed by
Andreas Köpf
parent
904f442f5a
commit
953d243a6f
@@ -4,17 +4,38 @@ parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
# switch to backend directory
|
||||
pushd "$parent_path/../../backend"
|
||||
|
||||
export DEBUG_SKIP_API_KEY_CHECK=True
|
||||
|
||||
python -m print_openapi_schema > oasst-openapi.json
|
||||
|
||||
MOCK_SERVER_PORT=8080
|
||||
OPENAPI_JSON_FILE_NAME=openapi.json
|
||||
|
||||
docker run --init --rm -d \
|
||||
-p $MOCK_SERVER_PORT:4010 \
|
||||
-v $(pwd):/tmp \
|
||||
-P stoplight/prism:4 \
|
||||
mock -h 0.0.0.0 "/tmp/oasst-openapi.json"
|
||||
echo "Generating OpenAPI schema..."
|
||||
python -m print_openapi_schema > $OPENAPI_JSON_FILE_NAME
|
||||
echo "Done!"
|
||||
|
||||
# If oasst-mock-backend docker container is already running,
|
||||
# just restart it
|
||||
if [ "$(docker ps -q -f name=oasst-mock-backend)" ]; then
|
||||
echo "oasst-mock-backend container exists, restarting..."
|
||||
docker restart oasst-mock-backend
|
||||
else
|
||||
echo "Creating new oasst-mock-backend container..."
|
||||
docker run --init --rm -d \
|
||||
--name oasst-mock-backend \
|
||||
-p $MOCK_SERVER_PORT:4010 \
|
||||
-v $(pwd):/tmp \
|
||||
-P stoplight/prism:4 \
|
||||
mock -h 0.0.0.0 "/tmp/$OPENAPI_JSON_FILE_NAME"
|
||||
fi
|
||||
|
||||
echo "Waiting for server to be live..."
|
||||
curl --retry-all-errors --retry 5 localhost:$MOCK_SERVER_PORT
|
||||
echo ""
|
||||
|
||||
# if return code is successful, print successful response
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Mock server is running at localhost:$MOCK_SERVER_PORT"
|
||||
else
|
||||
echo "Mock server failed to start"
|
||||
fi
|
||||
|
||||
|
||||
popd
|
||||
|
||||
Reference in New Issue
Block a user