Skip to content

Instantly share code, notes, and snippets.

@nvllsvm
Last active April 8, 2022 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nvllsvm/2c0e0561a3e472c9a53ba3bcd3be21eb to your computer and use it in GitHub Desktop.
Save nvllsvm/2c0e0561a3e472c9a53ba3bcd3be21eb to your computer and use it in GitHub Desktop.
services:
consul:
image: consul
example:
build: .
depends_on:
- consul
volumes:
- ./:/volume
environment:
CONSUL_HTTP_ADDR: consul:8500
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"]
#!/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)
@nvllsvm
Copy link
Author

nvllsvm commented Apr 8, 2022

Instructions

  1. docker-compose up -d
  2. Run this every few seconds docker-compose exec example ps -opid,ppid,pgid,stat,comm,args

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment