Skip to content

Commit e712dc9

Browse files
authored
Add HEALTHCHECKs to middleware containers (#27)
* Add healthcheck.sh * Add healthcheck logic for consumer/redoer containers Additionally: * Small update to readme * Add Q_URL env var to consumer entry im docker-compose
1 parent 0a68a59 commit e712dc9

File tree

6 files changed

+14
-5
lines changed

6 files changed

+14
-5
lines changed

.trivyignore.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@ misconfigurations:
22
# The tools Dockerfile doesn't need a healthcheck.
33
- id: AVD-DS-0026
44
paths:
5-
- Dockerfile.consumer # Jira -67
6-
- Dockerfile.redoer # Jira -67
75
- Dockerfile.exporter # ephemeral container, healthcheck not necessary
86
- Dockerfile.tools

Dockerfile.consumer

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ FROM senzing/senzingsdk-runtime:4.0.0
33
USER root
44

55
RUN apt-get update \
6-
&& apt-get -y install --no-install-recommends python3 python3-pip python3-boto3 \
6+
&& apt-get -y install --no-install-recommends python3 python3-pip python3-boto3 procps \
77
&& apt-get -y autoremove \
88
&& apt-get -y clean
99

1010
WORKDIR /app
1111
COPY middleware/* .
1212

13+
RUN chmod +x healthcheck.sh
14+
1315
# Add a new user and switch to it.
1416
RUN useradd -m -u 1001 senzing
1517
USER senzing
@@ -23,4 +25,6 @@ ENV PYTHONUNBUFFERED=1
2325
# Fargate.
2426
VOLUME ["/home/senzing", "/var/lib/amazon", "/var/log"]
2527

28+
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ./healthcheck.sh consumer.py || exit 1
29+
2630
CMD ["python3", "consumer.py"]

Dockerfile.redoer

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ RUN apt-get update \
1010
WORKDIR /app
1111
COPY middleware/* .
1212

13+
RUN chmod +x healthcheck.sh
14+
1315
# Add a new user and switch to it.
1416
RUN useradd -m -u 1001 senzing
1517
USER senzing
@@ -19,4 +21,6 @@ ENV PYTHONPATH=/opt/senzing/er/sdk/python:/app
1921
# Flush buffer - helps with print statements.
2022
ENV PYTHONUNBUFFERED=1
2123

24+
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ./healthcheck.sh redoer.py || exit 1
25+
2226
CMD ["python3", "redoer.py"]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ simultaneously as needed):
181181
```bash
182182
docker compose run --env AWS_PROFILE=localstack --env \
183183
Q_URL="http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/sqs-senzing-local-ingest" \
184-
--env LOG_LEVEL=INFO consumer
184+
--env LOG_LEVEL=DEBUG consumer
185185
```
186186

187187
`LOG_LEVEL` is optional; defaults to `INFO`.
@@ -191,7 +191,7 @@ simultaneously as needed):
191191
Similar to the consumer, the redoer is also a continually-running process.
192192

193193
```bash
194-
docker compose run --env AWS_PROFILE=localstack --env LOG_LEVEL=debug redoer
194+
docker compose run --env AWS_PROFILE=localstack --env LOG_LEVEL=DEBUG redoer
195195
```
196196

197197
`LOG_LEVEL` is optional; defaults to `INFO`.

docker-compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ services:
104104
"CONNECTION": "postgresql://${POSTGRES_USERNAME:-senzing}:${POSTGRES_PASSWORD:-senzing}@db:5432:${POSTGRES_DB:-G2}/?sslmode=disable"
105105
}
106106
}
107+
Q_URL: http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/sqs-senzing-local-ingest
107108
volumes:
108109
# Note: `.aws` mount might not be needed later.
109110
- ~/.aws:/home/senzing/.aws

middleware/healthcheck.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
ps -ef | grep $1 | grep -v grep

0 commit comments

Comments
 (0)