Last active
April 8, 2022 19:23
-
-
Save nvllsvm/2c0e0561a3e472c9a53ba3bcd3be21eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
consul: | |
image: consul | |
example: | |
build: . | |
depends_on: | |
- consul | |
volumes: | |
- ./:/volume | |
environment: | |
CONSUL_HTTP_ADDR: consul:8500 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.10-alpine | |
RUN wget -O - https://releases.hashicorp.com/envconsul/0.12.1/envconsul_0.12.1_linux_amd64.zip | unzip -d /usr/bin - \ | |
&& chmod +x /usr/bin/envconsul | |
COPY example.py /example.py | |
ENTRYPOINT ["/usr/bin/envconsul", "-log-level=debug", "-prefix=test"] | |
CMD ["python", "/example.py"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import signal | |
import time | |
if os.fork(): | |
# parent | |
time.sleep(1) | |
# assumes pid 1 == envconsul | |
os.kill(1, signal.SIGHUP) | |
else: | |
# child | |
signal.signal(signal.SIGINT, signal.SIG_IGN) | |
time.sleep(60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instructions
docker-compose up -d
docker-compose exec example ps -opid,ppid,pgid,stat,comm,args