Last active
December 30, 2020 14:09
-
-
Save hholst80/b520798ff3e838eb08bfa52923977784 to your computer and use it in GitHub Desktop.
Docker signal
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 as base | |
FROM base as target2 | |
COPY main2.py / | |
CMD python3 -u main2.py | |
FROM base as target1 | |
COPY main.py / | |
CMD python3 -u main.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
from time import sleep | |
import logging | |
try: | |
while True: | |
sleep(1) | |
print('hello') | |
except: | |
logging.exception('exception catched') |
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 time import sleep | |
import logging | |
from signal import signal, SIGINT, SIGTERM, SIGSTOP, SIGKILL | |
def handler(signum, frame): | |
print('signal num=%i frame: %s' % (signum, frame)) | |
signal(SIGINT, handler) | |
signal(SIGTERM, handler) | |
#signal(SIGSTOP, handler) | |
#signal(SIGKILL, handler) | |
try: | |
while True: | |
sleep(1) | |
print('hello') | |
except: | |
logging.exception('exception catched') |
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
#!/bin/sh | |
set -xe | |
docker build -t docker-restart . | |
docker run --name=docker-restart -d docker-restart | |
sleep 10 | |
docker stop docker-restart | |
docker logs docker-restart | |
docker rm docker-restart | |
docker rmi docker-restart |
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
#!/bin/sh | |
set -xe | |
docker build -t docker-restart . | |
docker run --init --name=docker-restart -d docker-restart | |
sleep 10 | |
docker stop docker-restart | |
docker logs docker-restart | |
docker rm docker-restart | |
docker rmi docker-restart |
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
#!/bin/sh | |
set -xe | |
docker build -t docker-restart --target=target2 . | |
docker run --name=docker-restart -d docker-restart | |
sleep 10 | |
docker stop docker-restart | |
docker logs docker-restart | |
docker rm docker-restart | |
docker rmi docker-restart |
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
#!/bin/sh | |
set -xe | |
docker build -t docker-restart --target=target2 . | |
docker run --init --name=docker-restart -d docker-restart | |
sleep 10 | |
docker stop docker-restart | |
docker logs docker-restart | |
docker rm docker-restart | |
docker rmi docker-restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment