diff --git a/tools/serving_build.sh b/tools/serving_build.sh index 445be45ed49e29c061a6f2b570bb9dd21bdf5de2..3a2ea2f2b66effae1f5597c66196cb2dd0584c05 100644 --- a/tools/serving_build.sh +++ b/tools/serving_build.sh @@ -1,5 +1,17 @@ #!/usr/bin/env bash +function unsetproxy() { + HTTP_PROXY_TEMP=$http_proxy + HTTPS_PROXY_TEMP=$https_proxy + unset http_proxy + unset https_proxy +} + +function setproxy() { + export http_proxy=$HTTP_PROXY_TEMP + export https_proxy=$HTTPS_PROXY_TEMP +} + function init() { source /root/.bashrc set -v @@ -90,16 +102,18 @@ function python_test_fit_a_line() { kill_server_process # test web + unsetproxy # maybe the proxy is used on iPipe, which makes web-test failed. check_cmd "python -m paddle_serving_server.serve --model uci_housing_model --name uci --port 9393 --thread 4 --name uci > /dev/null &" sleep 5 # wait for the server to start check_cmd "curl -H \"Content-Type:application/json\" -X POST -d '{\"x\": [0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332], \"fetch\":[\"price\"]}' http://127.0.0.1:9393/uci/prediction" # check http code http_code=`curl -H "Content-Type:application/json" -X POST -d '{"x": [0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332], "fetch":["price"]}' -s -w "%{http_code}" -o /dev/null http://127.0.0.1:9393/uci/prediction` + setproxy # recover proxy state + kill_server_process if [ ${http_code} -ne 200 ]; then echo "HTTP status code -ne 200" exit 1 fi - kill_server_process ;; GPU) # test rpc @@ -109,16 +123,18 @@ function python_test_fit_a_line() { kill_server_process # test web + unsetproxy # maybe the proxy is used on iPipe, which makes web-test failed. check_cmd "python -m paddle_serving_server_gpu.serve --model uci_housing_model --port 9393 --thread 2 --gpu_ids 0 --name uci > /dev/null &" sleep 5 # wait for the server to start check_cmd "curl -H \"Content-Type:application/json\" -X POST -d '{\"x\": [0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332], \"fetch\":[\"price\"]}' http://127.0.0.1:9393/uci/prediction" # check http code http_code=`curl -H "Content-Type:application/json" -X POST -d '{"x": [0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332], "fetch":["price"]}' -s -w "%{http_code}" -o /dev/null http://127.0.0.1:9393/uci/prediction` + setproxy # recover proxy state + kill_server_process if [ ${http_code} -ne 200 ]; then echo "HTTP status code -ne 200" exit 1 fi - kill_server_process ;; *) echo "error type"