Skip to content

Commit

Permalink
Use service environment vars, not setting new vars (#248)
Browse files Browse the repository at this point in the history
* no extra port env vars

* emailservice port undo

Co-authored-by: Carter Socha <43380952+cartersocha@users.noreply.github.com>
  • Loading branch information
mic-max and cartersocha authored Aug 3, 2022
1 parent 82c295e commit c32e394
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/adservice/src/main/java/hipstershop/AdService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
1 change: 0 additions & 1 deletion src/cartservice/src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ WORKDIR /usr/src/app/
COPY --from=builder /cartservice/ ./

EXPOSE ${CART_SERVICE_PORT}

ENTRYPOINT [ "./cartservice" ]
2 changes: 1 addition & 1 deletion src/currencyservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
2 changes: 1 addition & 1 deletion src/featureflagservice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/featureflagservice/config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -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"],
Expand Down
1 change: 0 additions & 1 deletion src/paymentservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ COPY ./src/paymentservice/ ./
COPY ./pb/demo.proto ./

EXPOSE ${PAYMENT_SERVICE_PORT}

ENTRYPOINT [ "node", "--require", "./tracing.js", "./index.js" ]
11 changes: 7 additions & 4 deletions src/paymentservice/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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()
}
)

Expand Down
3 changes: 1 addition & 2 deletions src/shippingservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion src/shippingservice/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
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();
Expand Down

0 comments on commit c32e394

Please sign in to comment.