forked from exozyme/scripts
healthcheck_containers.sh added
containers maintenance
This commit is contained in:
parent
20958f6bd6
commit
3b036c383d
1 changed files with 17 additions and 0 deletions
17
healthcheck_containers.sh
Normal file
17
healthcheck_containers.sh
Normal file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/sh
|
||||
|
||||
# To check if container is running and if found stopped it will restart it and also renews the unix socket.
|
||||
# Recommended to use with revive_pods.sh which is systemd service check certain containers hourly.
|
||||
|
||||
for container in "$@"; do
|
||||
status=$(podman inspect -f '{{.State.Status}}' $container)
|
||||
if [ "$status" = "exited" ]; then
|
||||
podman start $container && echo "Container $container started" || echo "failed to start container $container"
|
||||
rm /srv/http/$container && echo "reloaded clean socket file" || echo "failed to remove old socket file for $container"
|
||||
systemctl --user restart $container.service && echo "service restarted" || echo "failed to restart service"
|
||||
|
||||
else
|
||||
|
||||
echo "Container $container is $status"
|
||||
fi
|
||||
done
|
Loading…
Reference in a new issue