feat: add cleanup-worker script
This commit is contained in:
parent
1ddb5691ca
commit
77de05e856
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cleanup_docker() {
|
||||||
|
RUNNING_CONTAINERS=$(docker ps -q)
|
||||||
|
if [ ! -z "$RUNNING_CONTAINERS" ]; then
|
||||||
|
docker stop $RUNNING_CONTAINERS
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker system prune -f -a --volumes
|
||||||
|
docker network prune -f
|
||||||
|
|
||||||
|
service docker restart
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup_old_workspaces() {
|
||||||
|
# Suppression des workspaces dont la dernière date
|
||||||
|
# de modification est supérieure à 7 jours.
|
||||||
|
find /workspace -maxdepth 1 -type d -mtime +7 -exec rm -rf {} \;
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
cleanup_docker
|
||||||
|
cleanup_old_workspaces
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
Loading…
Reference in New Issue