From 049e922087af65f6882e0b8108cbecf6fec2aa2d Mon Sep 17 00:00:00 2001 From: Huynh Thanh Binh <1653006@student.hcmus.edu.vn> Date: Wed, 20 May 2020 16:37:49 +0700 Subject: [PATCH] [SERVER] update dev folder + add README for dev --- dev/README.md | 22 ++++++++++++++++ dev/service.sh | 5 ++++ dev/service_windows.sh | 54 ---------------------------------------- resources/references.txt | 7 ++++-- 4 files changed, 32 insertions(+), 56 deletions(-) create mode 100644 dev/README.md delete mode 100644 dev/service_windows.sh diff --git a/dev/README.md b/dev/README.md new file mode 100644 index 00000000..b7765933 --- /dev/null +++ b/dev/README.md @@ -0,0 +1,22 @@ +

Run SaigonParking environment

+Written by: Huynh Thanh Binh (bht) in May 20th, 2020
+ +Please do like following step to start saigonparking environment
+Please note that Windows is different from Ubuntu ! + +

First time run:

+ +(If you remove all the containers and create again, please redo) +- Run docker compose: +
   $ docker-compose up + +- Execute service.sh (For Windows user, please run Git Bash Here to begin terminal) +
   $ chmod +x service.sh +
   $ ./service.sh + +

Another time run:

+- Just run docker compose: +
   $ docker-compose up + +

Another frequently used command

+(Can be found in resources folder, file commands.txt) \ No newline at end of file diff --git a/dev/service.sh b/dev/service.sh index ce29e628..cbac44a1 100644 --- a/dev/service.sh +++ b/dev/service.sh @@ -1,9 +1,11 @@ #!/bin/sh +export MSYS_NO_PATHCONV=1 KONG_ADMIN_HOST=localhost KONG_ADMIN_PORT=8001 CONNECT_TIMEOUT=20000 +# create function to prevent boilerplate code registerService() { printf "\nRegister %s service\n" $1 curl -XPOST ${KONG_ADMIN_HOST}:${KONG_ADMIN_PORT}/services \ @@ -17,6 +19,7 @@ registerService() { printf "\n" } +# create function to prevent boilerplate code registerServiceGrpcRoute() { printf "\nRegister %s service gRPC route\n" $1 curl -XPOST ${KONG_ADMIN_HOST}:${KONG_ADMIN_PORT}/services/$1/routes \ @@ -52,3 +55,5 @@ SERVICE_PATH=/com.bht.saigonparking.api.grpc.parkinglot.ParkingLotService/ registerService ${SERVICE_NAME} ${SERVICE_HOST} ${SERVICE_PORT} ${CONNECT_TIMEOUT} registerServiceGrpcRoute ${SERVICE_NAME} ${SERVICE_PATH} + +export MSYS_NO_PATHCONV=0 diff --git a/dev/service_windows.sh b/dev/service_windows.sh deleted file mode 100644 index b4af95a8..00000000 --- a/dev/service_windows.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh - -KONG_ADMIN_HOST=localhost -KONG_ADMIN_PORT=8001 -CONNECT_TIMEOUT=20000 - -registerService() { - printf "\nRegister %s service\n" $1 - curl -XPOST ${KONG_ADMIN_HOST}:${KONG_ADMIN_PORT}/services ^ - --data name=$1 ^ - --data protocol=grpc ^ - --data host=$2 ^ - --data port=$3 ^ - --data connect_timeout=$4 ^ - --data write_timeout=$4 ^ - --data read_timeout=$4 - printf "\n" -} - -registerServiceGrpcRoute() { - printf "\nRegister %s service gRPC route\n" $1 - curl -XPOST ${KONG_ADMIN_HOST}:${KONG_ADMIN_PORT}/services/$1/routes ^ - --data protocols=grpc ^ - --data name=$1-grpc ^ - --data paths=$2 - printf "\n" -} - -# register Auth Service -SERVICE_NAME=auth -SERVICE_HOST=auth-service -SERVICE_PORT=7777 -SERVICE_PATH=/com.bht.saigonparking.api.grpc.auth.AuthService/ - -registerService ${SERVICE_NAME} ${SERVICE_HOST} ${SERVICE_PORT} ${CONNECT_TIMEOUT} -registerServiceGrpcRoute ${SERVICE_NAME} ${SERVICE_PATH} - -# register User Service -SERVICE_NAME=user -SERVICE_HOST=user-service -SERVICE_PORT=8888 -SERVICE_PATH=/com.bht.saigonparking.api.grpc.user.UserService/ - -registerService ${SERVICE_NAME} ${SERVICE_HOST} ${SERVICE_PORT} ${CONNECT_TIMEOUT} -registerServiceGrpcRoute ${SERVICE_NAME} ${SERVICE_PATH} - -# register ParkingLot Service -SERVICE_NAME=parkinglot -SERVICE_HOST=parkinglot-service -SERVICE_PORT=9999 -SERVICE_PATH=/com.bht.saigonparking.api.grpc.parkinglot.ParkingLotService/ - -registerService ${SERVICE_NAME} ${SERVICE_HOST} ${SERVICE_PORT} ${CONNECT_TIMEOUT} -registerServiceGrpcRoute ${SERVICE_NAME} ${SERVICE_PATH} diff --git a/resources/references.txt b/resources/references.txt index e6eca79d..54198a30 100644 --- a/resources/references.txt +++ b/resources/references.txt @@ -1,6 +1,6 @@ Document's name: Saigon Parking Project References Author: Huynh Thanh Binh -Last updated: Tue, May 19th, 2020 +Last updated: Wed, May 20th, 2020 ======================================================================================================================== 01. gRPC error handling: @@ -136,4 +136,7 @@ Last updated: Tue, May 19th, 2020 https://www.baeldung.com/convert-input-stream-to-array-of-bytes 45. gRPC: Random CANCELLED exception on RPC calls - gRPC Asynchronous Stub Calling - https://stackoverflow.com/questions/57110811/grpc-random-cancelled-exception-on-rpc-calls \ No newline at end of file + https://stackoverflow.com/questions/57110811/grpc-random-cancelled-exception-on-rpc-calls + +46. Git Bash confuse with Slash '/' when running bash script on Windows - Asked by me =)))) + https://stackoverflow.com/questions/61907994/git-bash-confuse-with-slash-when-running-bash-script-on-windows \ No newline at end of file