mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 06:19:44 +00:00
switch to auto-restarter daemon
This commit is contained in:
committed by
Keagan McClelland
parent
f68c13f57f
commit
30f8b8e6cd
7
agent/config/restarter.service
Normal file
7
agent/config/restarter.service
Normal 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
18
agent/config/restarter.sh
Normal 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
|
||||
9
agent/config/restarter.timer
Normal file
9
agent/config/restarter.timer
Normal file
@@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=restarter
|
||||
|
||||
[Timer]
|
||||
OnUnitActiveSec=60s
|
||||
OnBootSec=60s
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
Reference in New Issue
Block a user