diff --git a/docker-compose.yml b/docker-compose.yml index c3c56f9d26..7a115845e4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -128,7 +128,7 @@ services: ports: - "${CURRENCY_SERVICE_PORT}:${CURRENCY_SERVICE_PORT}" environment: - - PORT=${CURRENCY_SERVICE_PORT} + - CURRENCY_SERVICE_PORT - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT - OTEL_RESOURCE_ATTRIBUTES=service.name=currencyservice depends_on: @@ -248,7 +248,7 @@ services: ports: - "${SHIPPING_SERVICE_PORT}:${SHIPPING_SERVICE_PORT}" environment: - - PORT=${SHIPPING_SERVICE_PORT} + - SHIPPING_SERVICE_PORT - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT - OTEL_RESOURCE_ATTRIBUTES=service.name=shippingservice depends_on: @@ -265,8 +265,8 @@ services: - "${FEATURE_FLAG_SERVICE_PORT}:${FEATURE_FLAG_SERVICE_PORT}" - "${FEATURE_FLAG_GRPC_SERVICE_PORT}" environment: - - PORT=${FEATURE_FLAG_SERVICE_PORT} - - GRPC_PORT=${FEATURE_FLAG_GRPC_SERVICE_PORT} + - FEATURE_FLAG_SERVICE_PORT + - FEATURE_FLAG_GRPC_SERVICE_PORT - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT - OTEL_RESOURCE_ATTRIBUTES=service.name=featureflagservice - DATABASE_URL=ecto://ffs:ffs@ffs_postgres:5432/ffs diff --git a/src/adservice/src/main/java/hipstershop/AdService.java b/src/adservice/src/main/java/hipstershop/AdService.java index b0b9fe0f96..c449713461 100644 --- a/src/adservice/src/main/java/hipstershop/AdService.java +++ b/src/adservice/src/main/java/hipstershop/AdService.java @@ -58,7 +58,7 @@ public final class AdService { private static final AdService service = new AdService(); private void start() throws IOException { - int port = Integer.parseInt(System.getenv().getOrDefault("AD_SERVICE_PORT", "9555")); + int port = Integer.parseInt(System.getenv("AD_SERVICE_PORT")); healthMgr = new HealthStatusManager(); server = diff --git a/src/cartservice/src/Dockerfile b/src/cartservice/src/Dockerfile index 22c309a3b4..b76af3a281 100644 --- a/src/cartservice/src/Dockerfile +++ b/src/cartservice/src/Dockerfile @@ -32,5 +32,4 @@ WORKDIR /usr/src/app/ COPY --from=builder /cartservice/ ./ EXPOSE ${CART_SERVICE_PORT} - ENTRYPOINT [ "./cartservice" ] diff --git a/src/currencyservice/Dockerfile b/src/currencyservice/Dockerfile index af18848e19..5257a2ac28 100644 --- a/src/currencyservice/Dockerfile +++ b/src/currencyservice/Dockerfile @@ -56,4 +56,4 @@ RUN cd /currencyservice \ && mkdir -p build && cd build \ && cmake .. && make -j install -ENTRYPOINT currencyservice ${PORT} ${OTEL_EXPORTER_OTLP_TRACES_ENDPOINT} ${OTEL_RESOURCE_ATTRIBUTES} +ENTRYPOINT currencyservice ${CURRENCY_SERVICE_PORT} ${OTEL_EXPORTER_OTLP_TRACES_ENDPOINT} ${OTEL_RESOURCE_ATTRIBUTES} diff --git a/src/featureflagservice/README.md b/src/featureflagservice/README.md index cd7816279d..ad373ed5e5 100644 --- a/src/featureflagservice/README.md +++ b/src/featureflagservice/README.md @@ -22,7 +22,7 @@ docker compose up And run the Release: ``` shell -PHX_SERVER=1 PORT=4000 GRPC_PORT=4001 _build/prod/rel/featureflagservice/bin/featureflagservice start_iex +PHX_SERVER=1 FEATURE_FLAG_SERVICE_PORT=4000 FEATURE_FLAG_GRPC_SERVICE_PORT=4001 _build/prod/rel/featureflagservice/bin/featureflagservice start_iex ``` ## Instrumentation diff --git a/src/featureflagservice/config/runtime.exs b/src/featureflagservice/config/runtime.exs index 844f8b96e0..9b6dab5cff 100644 --- a/src/featureflagservice/config/runtime.exs +++ b/src/featureflagservice/config/runtime.exs @@ -4,7 +4,7 @@ if System.get_env("PHX_SERVER") do config :featureflagservice, FeatureflagserviceWeb.Endpoint, server: true end -grpc_port = String.to_integer(System.get_env("GRPC_PORT") || "4001") +grpc_port = String.to_integer(System.get_env("FEATURE_FLAG_GRPC_SERVICE_PORT")) config :grpcbox, servers: [ @@ -51,7 +51,7 @@ if config_env() == :prod do """ host = System.get_env("PHX_HOST") || "localhost" - port = String.to_integer(System.get_env("PORT") || "4000") + port = String.to_integer(System.get_env("FEATURE_FLAG_SERVICE_PORT")) config :featureflagservice, FeatureflagserviceWeb.Endpoint, url: [host: host, port: 443, scheme: "https"], diff --git a/src/paymentservice/Dockerfile b/src/paymentservice/Dockerfile index f603e6640b..6c03e62579 100644 --- a/src/paymentservice/Dockerfile +++ b/src/paymentservice/Dockerfile @@ -33,5 +33,4 @@ COPY ./src/paymentservice/ ./ COPY ./pb/demo.proto ./ EXPOSE ${PAYMENT_SERVICE_PORT} - ENTRYPOINT [ "node", "--require", "./tracing.js", "./index.js" ] diff --git a/src/paymentservice/index.js b/src/paymentservice/index.js index a6bf8f8853..755fdc07e3 100644 --- a/src/paymentservice/index.js +++ b/src/paymentservice/index.js @@ -55,7 +55,6 @@ async function closeGracefully(signal) { // Main const logger = pino() -const port = process.env['PAYMENT_SERVICE_PORT'] const hipsterShopPackage = grpc.loadPackageDefinition(protoLoader.loadSync('demo.proto')) const server = new grpc.Server() @@ -65,9 +64,13 @@ server.addService(health.service, new health.Implementation({ server.addService(hipsterShopPackage.hipstershop.PaymentService.service, { charge: chargeServiceHandler }) -server.bindAsync(`0.0.0.0:${port}`, grpc.ServerCredentials.createInsecure(), () => { - logger.info(`PaymentService gRPC server started on port ${port}`) - server.start() +server.bindAsync(`0.0.0.0:${process.env['PAYMENT_SERVICE_PORT']}`, grpc.ServerCredentials.createInsecure(), (err, port) => { + if (err) { + return logger.error(err) + } + + logger.info(`PaymentService gRPC server started on port ${port}`) + server.start() } ) diff --git a/src/shippingservice/Dockerfile b/src/shippingservice/Dockerfile index eabde95342..e198fee9b6 100644 --- a/src/shippingservice/Dockerfile +++ b/src/shippingservice/Dockerfile @@ -16,7 +16,6 @@ RUN GRPC_HEALTH_PROBE_VERSION=v0.4.7 && \ chmod +x /bin/grpc_health_probe WORKDIR /app COPY --from=builder /app/target/release/shippingservice /shippingservice -ENV PORT=50052 -EXPOSE 50052 +EXPOSE ${SHIPPING_SERVICE_PORT} ENTRYPOINT ["/shippingservice"] diff --git a/src/shippingservice/src/main.rs b/src/shippingservice/src/main.rs index b4d913a23a..34fe03741f 100644 --- a/src/shippingservice/src/main.rs +++ b/src/shippingservice/src/main.rs @@ -53,7 +53,7 @@ async fn main() -> Result<(), Box> { init_logger()?; init_tracer()?; info!("OTel pipeline created"); - let port = env::var("PORT").unwrap_or_else(|_| "50050".to_string()); + let port = env::var("SHIPPING_SERVICE_PORT").expect("$SHIPPING_SERVICE_PORT is not set"); let addr = format!("0.0.0.0:{}", port).parse()?; info!("listening on {}", addr); let shipper = ShippingServer::default();