Skip to content

Commit

Permalink
Add Makefile for deploy, maintainance.sh for misc maintananace
Browse files Browse the repository at this point in the history
  • Loading branch information
fono09 committed Mar 5, 2024
1 parent 66aff99 commit ce1f42c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Makefile
@@ -0,0 +1,11 @@
stack = mastodon
envfile = ./.env.production

include $(envfile)
export

up:
docker stack deploy -c docker-compose.yml $(stack)

config:
docker compose -f docker-compose.yml config
13 changes: 13 additions & 0 deletions docker-compose.yml
Expand Up @@ -122,6 +122,19 @@ services:
restart_policy:
condition: none

maintainance:
<<: *web
command: bash -c "bin/tootctl accounts prune && bin/tootctl media remove"
healthcheck:
test: ""
ports: []
deploy:
placement:
constraints: [node.hostname == okaya]
replicas: 0
restart_policy:
condition: none

after_migration:
<<: *web
command: bash -c "bundle exec rails db:migrate"
Expand Down
21 changes: 21 additions & 0 deletions maintainance.sh
@@ -0,0 +1,21 @@
#!/bin/bash
set -euxo pipefail

cd `dirname $0`
pwd

SERVICE_NAME=mastodon_maintainance

get_service_state(){
echo `docker service ps --format '{{ .DesiredState }}' $1`
}

if [[ `get_service_state $SERVICE_NAME` != "Running" ]]; then
docker service scale $SERVICE_NAME=1
fi

while [[ `get_service_state $SERVICE_NAME` == "Running" ]]; do
sleep 10
done

docker service scale $SERVICE_NAME=0

0 comments on commit ce1f42c

Please sign in to comment.