Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use service environment vars, not setting new vars #248

Merged
merged 7 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ services:
ports:
- "${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 All @@ -144,7 +144,7 @@ services:
- "${EMAIL_SERVICE_PORT}"
environment:
- APP_ENV=production
- PORT=${EMAIL_SERVICE_PORT}
- EMAIL_SERVICE_PORT
mic-max marked this conversation as resolved.
Show resolved Hide resolved
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://otelcol:4318/v1/traces
- OTEL_RESOURCE_ATTRIBUTES=service.name=emailservice
depends_on:
Expand Down Expand Up @@ -247,7 +247,7 @@ services:
ports:
- "${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 @@ -264,8 +264,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=50051

EXPOSE 50051
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(|_| "50051".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