From 987274ae8540882fd2c929b2486c4830e5efd790 Mon Sep 17 00:00:00 2001 From: slinkydeveloper Date: Mon, 25 Sep 2023 12:13:55 +0200 Subject: [PATCH] Update port numbers --- README.md | 6 +++--- typescript/ecommerce-store/README.md | 2 +- typescript/ecommerce-store/deployment/aws/README.md | 2 +- .../deployment/aws/services/webapp/main.tf | 2 +- .../ecommerce-store/deployment/aws/variables.tf | 4 ++-- .../deployment/docker/docker-compose-pg.yml | 8 +++----- .../deployment/docker/docker-compose.yml | 8 +++----- .../ecommerce-store/deployment/knative/README.md | 6 +++--- .../ecommerce-store/deployment/knative/deploy.yaml | 12 ++++++------ .../ecommerce-store/deployment/local/init_state.sh | 2 +- .../react-shopping-cart/src/services/grpc.ts | 2 +- typescript/ecommerce-store/services/Dockerfile | 1 + typescript/ecommerce-store/services/src/app.ts | 2 +- typescript/food-ordering/README.md | 6 +++--- typescript/food-ordering/docker-compose.yml | 12 +++++------- typescript/food-ordering/pos_server/src/server.ts | 2 +- typescript/food-ordering/services/Dockerfile | 1 + typescript/food-ordering/services/src/app.ts | 2 +- typescript/payment-api/README.md | 4 ++-- typescript/payment-api/src/payment_service.ts | 2 +- typescript/ticket-reservation/README.md | 4 ++-- typescript/ticket-reservation/src/app.ts | 2 +- 22 files changed, 44 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 2c6080e6..2a6c1a43 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Have a look at how to start up the runtime in a Docker container in [this reposi - For MacOS: ```shell -docker run --name restate_dev --rm -p 8081:8081 -p 9091:9091 -p 9090:9090 -p 5432:5432 ghcr.io/restatedev/restate-dist:latest +docker run --name restate_dev --rm -p 8080:8080 -p 9070:9070 -p 9071:9071 ghcr.io/restatedev/restate-dist:latest ``` - For Linux: ```shell @@ -47,11 +47,11 @@ Once the runtime is up, let it discover the services of the examples by executin - For MacOS: ```shell -curl -X POST http://localhost:8081/endpoints -H 'content-type: application/json' -d '{"uri": "http://host.docker.internal:8080"}' +curl -X POST http://localhost:9070/endpoints -H 'content-type: application/json' -d '{"uri": "http://host.docker.internal:9080"}' ``` - For Linux: ```shell -curl -X POST http://localhost:8081/endpoints -H 'content-type: application/json' -d '{"uri": "http://localhost:8080"}' +curl -X POST http://localhost:9070/endpoints -H 'content-type: application/json' -d '{"uri": "http://localhost:9080"}' ``` This should give you the following output in case of the ticket reservation example: diff --git a/typescript/ecommerce-store/README.md b/typescript/ecommerce-store/README.md index c8adfb69..8efd911e 100644 --- a/typescript/ecommerce-store/README.md +++ b/typescript/ecommerce-store/README.md @@ -86,7 +86,7 @@ Local deployment doesn't use a pre-filled database, so you need to manually fill ```shell cd deployment/local -./init_state.sh "localhost:9090" +./init_state.sh "localhost:8080" ``` Go to http://localhost:3000 to see the UI and buy some products. diff --git a/typescript/ecommerce-store/deployment/aws/README.md b/typescript/ecommerce-store/deployment/aws/README.md index f63a3945..34e79b4d 100644 --- a/typescript/ecommerce-store/deployment/aws/README.md +++ b/typescript/ecommerce-store/deployment/aws/README.md @@ -74,7 +74,7 @@ ssh -i shopping-demo-key.pem -L 5050:pgadmin.shopping-cart-demo:5050 -L 16686:ja Then discover the services from within the ssh session: ```shell -curl -X POST http://restate-runtime.shopping-cart-demo:8081/endpoints -H 'content-type: application/json' -d '{"uri": "http://shopping-services.shopping-cart-demo:8080"}' +curl -X POST http://restate-runtime.shopping-cart-demo:9070/endpoints -H 'content-type: application/json' -d '{"uri": "http://shopping-services.shopping-cart-demo:8080"}' ``` This prints out the services were discovered by the Restate runtime. diff --git a/typescript/ecommerce-store/deployment/aws/services/webapp/main.tf b/typescript/ecommerce-store/deployment/aws/services/webapp/main.tf index ee89b628..43d4c2ad 100644 --- a/typescript/ecommerce-store/deployment/aws/services/webapp/main.tf +++ b/typescript/ecommerce-store/deployment/aws/services/webapp/main.tf @@ -42,7 +42,7 @@ resource "aws_ecs_task_definition" "webapp" { environment = [ { name = "REACT_APP_RESTATE_HOST", - value = "http://localhost:9090" + value = "http://localhost:8080" }, { name = "REACT_APP_DATABASE_ENABLED", diff --git a/typescript/ecommerce-store/deployment/aws/variables.tf b/typescript/ecommerce-store/deployment/aws/variables.tf index 498ce91f..e45bab33 100644 --- a/typescript/ecommerce-store/deployment/aws/variables.tf +++ b/typescript/ecommerce-store/deployment/aws/variables.tf @@ -36,12 +36,12 @@ variable "service_desired_count" { variable "restate_runtime_ingress_port" { description = "The port of the restate runtime ingress endpoint" - default = 9090 + default = 8080 } variable "restate_runtime_discovery_port" { description = "The port of the restate runtime to register service endpoints" - default = 8081 + default = 9070 } variable "webapp_port" { diff --git a/typescript/ecommerce-store/deployment/docker/docker-compose-pg.yml b/typescript/ecommerce-store/deployment/docker/docker-compose-pg.yml index 904e25be..4a356cd9 100644 --- a/typescript/ecommerce-store/deployment/docker/docker-compose-pg.yml +++ b/typescript/ecommerce-store/deployment/docker/docker-compose-pg.yml @@ -2,8 +2,6 @@ version: "3.3" services: services: image: dev.local/shopping-cart/services:0.0.1 - ports: - - "8080:8080" environment: - DATABASE_ENABLED=true - RESTATE_DEBUG_LOGGING=JOURNAL_VERBOSE @@ -22,8 +20,8 @@ services: - services - jaeger ports: - - "9090:9090" - - "8081:8081" + - "8080:8080" + - "9070:9070" environment: - RUST_LOG=info,restate=debug - RESTATE_OBSERVABILITY__TRACING__ENDPOINT=http://jaeger:4317 @@ -34,7 +32,7 @@ services: - runtime - services restart: "no" - entrypoint: ["sh", "-c", "sleep 5 && curl -X POST 'runtime:8081/endpoints' -H 'content-type: application/json' -d '{\"uri\": \"http://services:8080\"}' || exit 1"] + entrypoint: ["sh", "-c", "sleep 5 && curl -X POST 'runtime:9070/endpoints' -H 'content-type: application/json' -d '{\"uri\": \"http://services:8080\"}' || exit 1"] db: image: 'postgres:15.0-alpine' diff --git a/typescript/ecommerce-store/deployment/docker/docker-compose.yml b/typescript/ecommerce-store/deployment/docker/docker-compose.yml index ec7c2a0e..994731d5 100644 --- a/typescript/ecommerce-store/deployment/docker/docker-compose.yml +++ b/typescript/ecommerce-store/deployment/docker/docker-compose.yml @@ -5,8 +5,6 @@ services: environment: - RESTATE_DEBUG_LOGGING=JOURNAL_VERBOSE - DATABASE_ENABLED=false - ports: - - "8080:8080" jaeger: image: jaegertracing/all-in-one:1.47 @@ -22,8 +20,8 @@ services: - services - jaeger ports: - - "9090:9090" - - "8081:8081" + - "8080:8080" + - "9070:9070" environment: - RUST_LOG=info,restate=debug - RESTATE_OBSERVABILITY__TRACING__ENDPOINT=http://jaeger:4317 @@ -38,7 +36,7 @@ services: - ../local/:/scripts - ../data/:/data entrypoint: ["sh", "-c", "sleep 5 && apk add --no-cache bash jq curl && - curl -X POST 'runtime:8081/endpoints' -H 'content-type: application/json' -d '{\"uri\": \"http://services:8080\"}' && + curl -X POST 'runtime:9070/endpoints' -H 'content-type: application/json' -d '{\"uri\": \"http://services:8080\"}' && sleep 3 && cd /scripts && chmod +x init_state.sh && ./init_state.sh runtime:9090 || exit 1"] diff --git a/typescript/ecommerce-store/deployment/knative/README.md b/typescript/ecommerce-store/deployment/knative/README.md index 2c6b849e..21ee4bc4 100644 --- a/typescript/ecommerce-store/deployment/knative/README.md +++ b/typescript/ecommerce-store/deployment/knative/README.md @@ -49,18 +49,18 @@ You can visit the web app at http://localhost:3000 6. Forwards the ports of the Restate runtime: ```shell -kubectl port-forward -n shopping-cart svc/restate-runtime 8081:8081 9090:9090 +kubectl port-forward -n shopping-cart svc/restate-runtime 8080:8080 9070:9070 ``` 7. Execute the service discovery: ```shell -curl -X POST http://localhost:8081/endpoint/discover -H 'content-type: application/json' -d '{"uri": "http://services.shopping-cart.svc.cluster.local"}' +curl -X POST http://localhost:9070/endpoint/discover -H 'content-type: application/json' -d '{"uri": "http://services.shopping-cart.svc.cluster.local"}' ``` 8. Fill the state of the product service with a list of products: ```shell -cd deployment/local && ./init_state.sh "localhost:9090" && cd - +cd deployment/local && ./init_state.sh "localhost:8080" && cd - ``` 6. Watch pods of the application diff --git a/typescript/ecommerce-store/deployment/knative/deploy.yaml b/typescript/ecommerce-store/deployment/knative/deploy.yaml index 65308668..c5fbd7c4 100644 --- a/typescript/ecommerce-store/deployment/knative/deploy.yaml +++ b/typescript/ecommerce-store/deployment/knative/deploy.yaml @@ -19,9 +19,9 @@ spec: image: ghcr.io/restatedev/restate-dist:latest imagePullPolicy: Never ports: - - containerPort: 9090 + - containerPort: 8080 name: grpc - - containerPort: 8081 + - containerPort: 9070 name: meta --- @@ -36,13 +36,13 @@ spec: app: restate-runtime ports: - name: grpc - port: 9090 + port: 8080 protocol: TCP - targetPort: 9090 + targetPort: 8080 - name: meta - port: 8081 + port: 9070 protocol: TCP - targetPort: 8081 + targetPort: 9070 --- apiVersion: apps/v1 diff --git a/typescript/ecommerce-store/deployment/local/init_state.sh b/typescript/ecommerce-store/deployment/local/init_state.sh index bb186f10..119a90d3 100755 --- a/typescript/ecommerce-store/deployment/local/init_state.sh +++ b/typescript/ecommerce-store/deployment/local/init_state.sh @@ -1,5 +1,5 @@ #!/bin/bash -export RESTATE_HOST=${1:-localhost:9090} +export RESTATE_HOST=${1:-localhost:8080} jq -c '.data.products[]' ../data/products.json | while read i; do id=$(echo $i | jq -r '.id') quantity=$(echo $i | jq -r '.installments') diff --git a/typescript/ecommerce-store/react-shopping-cart/src/services/grpc.ts b/typescript/ecommerce-store/react-shopping-cart/src/services/grpc.ts index 7b72935c..c4a40f12 100644 --- a/typescript/ecommerce-store/react-shopping-cart/src/services/grpc.ts +++ b/typescript/ecommerce-store/react-shopping-cart/src/services/grpc.ts @@ -1,6 +1,6 @@ import axios from 'axios'; export const grpc = async (service: string, method: string, data: any) => { - const RESTATE_HOST = process.env.REACT_APP_RESTATE_HOST || "http://localhost:9090" + const RESTATE_HOST = process.env.REACT_APP_RESTATE_HOST || "http://localhost:8080" return await (await axios.post(`${RESTATE_HOST}/io.shoppingcart.${service}/${method}`, data)).data; }; diff --git a/typescript/ecommerce-store/services/Dockerfile b/typescript/ecommerce-store/services/Dockerfile index b9092175..1d75bec6 100644 --- a/typescript/ecommerce-store/services/Dockerfile +++ b/typescript/ecommerce-store/services/Dockerfile @@ -16,6 +16,7 @@ RUN npm run build ENV NODE_ENV production +ENV PORT 8080 EXPOSE 8080 USER node CMD ["dumb-init", "node", "./dist/app.js"] \ No newline at end of file diff --git a/typescript/ecommerce-store/services/src/app.ts b/typescript/ecommerce-store/services/src/app.ts index 223d33c3..fa379dad 100644 --- a/typescript/ecommerce-store/services/src/app.ts +++ b/typescript/ecommerce-store/services/src/app.ts @@ -81,4 +81,4 @@ if (process.env.DATABASE_ENABLED === "true") { }); } -restateServer.listen(8080); +restateServer.listen(); diff --git a/typescript/food-ordering/README.md b/typescript/food-ordering/README.md index 977242c3..dfc1b3d6 100644 --- a/typescript/food-ordering/README.md +++ b/typescript/food-ordering/README.md @@ -77,7 +77,7 @@ Create a new order for five cheeseburgers at `FastFood123` with immediate delive You can do this via curl: ```shell -curl -X POST http://localhost:9090/OrderService/createOrder -H 'content-type: application/json' -d '{ +curl -X POST http://localhost:8080/OrderService/createOrder -H 'content-type: application/json' -d '{ "key": "134", "request": {"restaurantId": "FastFood123", "deliveryDelay": 0, "items": [{"productName": "cheeseburger", "quantity": 5}]} }' @@ -86,7 +86,7 @@ curl -X POST http://localhost:9090/OrderService/createOrder -H 'content-type: ap Create a new order for five cheeseburgers at `FastFood123` with delivery delayed for 10 seconds: ```shell -curl -X POST http://localhost:9090/OrderService/createOrder -H 'content-type: application/json' -d '{ +curl -X POST http://localhost:8080/OrderService/createOrder -H 'content-type: application/json' -d '{ "key": "174", "request": {"restaurantId": "FastFood123", "deliveryDelay": 10000, "items": [{"productName": "cheeseburger", "quantity": 5}]} }' @@ -95,7 +95,7 @@ curl -X POST http://localhost:9090/OrderService/createOrder -H 'content-type: ap You can also check the status of the delivery via: ```shell -curl -X POST http://localhost:9090/OrderService/getOrderStatus -H 'content-type: application/json' -d '{ "key": "174" }' +curl -X POST http://localhost:8080/OrderService/getOrderStatus -H 'content-type: application/json' -d '{ "key": "174" }' ``` To understand the requests that are done, you can have a look at the logs of the runtime, service and PoS server. diff --git a/typescript/food-ordering/docker-compose.yml b/typescript/food-ordering/docker-compose.yml index 4a4647a8..3c58749c 100644 --- a/typescript/food-ordering/docker-compose.yml +++ b/typescript/food-ordering/docker-compose.yml @@ -6,8 +6,6 @@ services: environment: - RESTATE_DEBUG_LOGGING=JOURNAL_VERBOSE - POS_ENDPOINT=http://pos_server:5050 - ports: - - "8080:8080" jaeger: image: jaegertracing/all-in-one:1.47 @@ -23,8 +21,8 @@ services: - services - jaeger ports: - - "9090:9090" - - "8081:8081" + - "8080:8080" + - "9070:9070" environment: - RESTATE_OBSERVABILITY__TRACING__ENDPOINT=http://jaeger:4317 @@ -35,7 +33,7 @@ services: - services restart: "no" entrypoint: ["sh", "-c", "sleep 5 && apk add --no-cache bash jq curl && - curl -X POST 'runtime:8081/endpoints' -H 'content-type: application/json' -d '{\"uri\": \"http://services:8080\"}' + curl -X POST 'runtime:9070/endpoints' -H 'content-type: application/json' -d '{\"uri\": \"http://services:8080\"}' || exit 1"] grpcui: @@ -45,13 +43,13 @@ services: depends_on: runtimesetup: condition: service_completed_successfully - entrypoint: ["/bin/grpcui", "-bind=0.0.0.0", "-port=3030", "-plaintext", "runtime:9090"] + entrypoint: ["/bin/grpcui", "-bind=0.0.0.0", "-port=3030", "-plaintext", "runtime:8080"] pos_server: image: dev.local/food-ordering/pos_server:0.0.1 depends_on: - runtimesetup environment: - - RESTATE_RUNTIME_ENDPOINT=http://runtime:9090 + - RESTATE_RUNTIME_ENDPOINT=http://runtime:8080 ports: - "5050:5050" diff --git a/typescript/food-ordering/pos_server/src/server.ts b/typescript/food-ordering/pos_server/src/server.ts index c08ffad2..8e34896b 100644 --- a/typescript/food-ordering/pos_server/src/server.ts +++ b/typescript/food-ordering/pos_server/src/server.ts @@ -18,7 +18,7 @@ import axios from "axios"; */ const RESTATE_RUNTIME_ENDPOINT = - process.env.RESTATE_RUNTIME_ENDPOINT || "http://localhost:9090"; + process.env.RESTATE_RUNTIME_ENDPOINT || "http://localhost:8080"; const app = express(); const port = 5050; diff --git a/typescript/food-ordering/services/Dockerfile b/typescript/food-ordering/services/Dockerfile index e1cb87f9..d2a59a83 100644 --- a/typescript/food-ordering/services/Dockerfile +++ b/typescript/food-ordering/services/Dockerfile @@ -17,5 +17,6 @@ RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm prune --omit=dev ENV NODE_ENV production EXPOSE 8080 +ENV PORT 8080 USER node CMD ["dumb-init", "node", "./dist/app.js"] diff --git a/typescript/food-ordering/services/src/app.ts b/typescript/food-ordering/services/src/app.ts index 96108912..24f4eacb 100644 --- a/typescript/food-ordering/services/src/app.ts +++ b/typescript/food-ordering/services/src/app.ts @@ -16,4 +16,4 @@ import { orderApi, orderService } from "./order_service"; restate .createServer() .bindKeyedRouter(orderApi.path, orderService) - .listen(8080); + .listen(); diff --git a/typescript/payment-api/README.md b/typescript/payment-api/README.md index a8311d46..dcc8bf34 100644 --- a/typescript/payment-api/README.md +++ b/typescript/payment-api/README.md @@ -43,11 +43,11 @@ Now [launch the runtime](../../README.md#launching-the-runtime) and [discover th Make a sample payment. The 'key' parameter is the idempotency token. ```shell -curl -X POST localhost:9090/payments/makePayment -H 'content-type: application/json' -d '{"key": "some-string-id", "request": { "accountId": "abc", "amount": 100 } }' +curl -X POST localhost:8080/payments/makePayment -H 'content-type: application/json' -d '{"key": "some-string-id", "request": { "accountId": "abc", "amount": 100 } }' ``` Cancel a payment. The 'key' parameter is the idempotency token, there is no further request data. ```shell -curl -X POST localhost:9090/payments/cancelPayment -H 'content-type: application/json' -d '{"key": "some-string-id"}' +curl -X POST localhost:8080/payments/cancelPayment -H 'content-type: application/json' -d '{"key": "some-string-id"}' ``` diff --git a/typescript/payment-api/src/payment_service.ts b/typescript/payment-api/src/payment_service.ts index 23824dbe..e38848f5 100644 --- a/typescript/payment-api/src/payment_service.ts +++ b/typescript/payment-api/src/payment_service.ts @@ -117,7 +117,7 @@ restate .createServer() .bindKeyedRouter("payments", rounter) .bindKeyedRouter("accounts", accounts.router) - .listen(8080); + .listen(); // ---------------------------------------------------------------------------- // miscellaneous utils diff --git a/typescript/ticket-reservation/README.md b/typescript/ticket-reservation/README.md index 7fd9f186..9741bc01 100644 --- a/typescript/ticket-reservation/README.md +++ b/typescript/ticket-reservation/README.md @@ -100,7 +100,7 @@ Now [launch the runtime](../../README.md#launching-the-runtime) and [discover th We can now invoke the `addTicket` method of the user session service by executing: ```shell -curl -X POST http://localhost:9090/UserSession/addTicket -H 'content-type: application/json' -d '{"key": "user_1", "request": "Rolling-stones-A22"}' +curl -X POST http://localhost:8080/UserSession/addTicket -H 'content-type: application/json' -d '{"key": "user_1", "request": "Rolling-stones-A22"}' ``` The first time, this should give us `true` back. The second time, it returns `false` @@ -109,7 +109,7 @@ because a single seat cannot be reserved twice. Now let user `user_1` buy the ticket by calling the `checkout` method of the user session service: ```shell -curl -X POST http://localhost:9090/UserSession/checkout -H 'content-type: application/json' -d '{"key": "user_1"}' +curl -X POST http://localhost:8080/UserSession/checkout -H 'content-type: application/json' -d '{"key": "user_1"}' ``` That's it! We managed to run the example, add a ticket to the user session cart, and buy it! diff --git a/typescript/ticket-reservation/src/app.ts b/typescript/ticket-reservation/src/app.ts index 7c83ffb3..ac4758b8 100644 --- a/typescript/ticket-reservation/src/app.ts +++ b/typescript/ticket-reservation/src/app.ts @@ -19,4 +19,4 @@ restate .bindKeyedRouter(userSessionApi.path, userSessionRouter) .bindKeyedRouter(ticketDbApi.path, ticketDbRouter) .bindRouter(checkoutApi.path, checkoutRouter) - .listen(8080); + .listen();