I have simple akka-http server. (Java) . I am able to keep the server running with System.in.read() as shown in the documentation. However the server immediately crashes when running on the docker container. Here is my code and relevant information. Any help will be really appreciated.
final Flow<HttpRequest, HttpResponse, NotUsed> routeFlow = application
.route(createIngestionRoutes(),
createHealthRoutes(),
createResourceRoutes())
.flow(actorSystem, materializer);
final CompletionStage<ServerBinding> binding = http.bindAndHandle(routeFlow,
ConnectHttp.toHost("0.0.0.0", 8080),
materializer);
//binding.toCompletableFuture().get();
// System.out.println("Server online at http://localhost:8010/\nPress RETURN to stop...");
System.in.read(); // let it run until user presses return
DOCKERFILE:
FROM openjdk:8-jre
ADD jar-all.jar /app/app.jar
EXPOSE 8010 19999 2552 8080
WORKDIR /app
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
akka-cluster.yml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: appname
name: appname
spec:
replicas: 3
selector:
matchLabels:
app: appname
template:
metadata:
labels:
app: appname
actorSystemName: actor-system
spec:
containers:
- name: appname
image: imagename:2.0
imagePullPolicy: Never
env:
- name: HOST_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
- name: NETWORK_HOST
value: _eth0_
livenessProbe:
tcpSocket:
port: 19999
initialDelaySeconds: 60
ports:
# akka remoting
- name: remoting
containerPort: 2552
protocol: TCP
# akka-management bootstrap
- name: bootstrap
containerPort: 8010
protocol: TCP
# external http
- name: akka-mgmt-http
containerPort: 19999
protocol: TCP
---
kind: Service
apiVersion: v1
metadata:
name: servicename-service
spec:
clusterIP: None
selector:
app: appname
ports:
- protocol: TCP
port: 8010
targetPort: 8010