switch to auto-restarter daemon

This commit is contained in:
Aiden McClelland
2020-12-01 21:36:50 -07:00
committed by Keagan McClelland
parent f68c13f57f
commit 30f8b8e6cd
5 changed files with 61 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
[Unit]
Description=restarts dead containers
Requires=docker.service
[Service]
Type=oneshot
ExecStart=/bin/bash /root/restarter.sh

18
agent/config/restarter.sh Normal file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
for CONTAINER in $(docker ps -aq); do
EXIT=`docker inspect -f "{{ .State.ExitCode }}" $CONTAINER`
if [ $EXIT -eq 0 ]; then
continue
fi
if [ $EXIT -eq 143 ]; then
continue
fi
if [ $EXIT -eq 137 ]; then
OOM=`docker inspect -f "{{ .State.OOMKilled }}" $CONTAINER`
if [ "$OOM" == "false" ]; then
continue
fi
fi
docker start $CONTAINER
done

View File

@@ -0,0 +1,9 @@
[Unit]
Description=restarter
[Timer]
OnUnitActiveSec=60s
OnBootSec=60s
[Install]
WantedBy=timers.target