Skip to content

Commit

Permalink
Fix restore command
Browse files Browse the repository at this point in the history
  • Loading branch information
dhelonious committed Sep 20, 2024
1 parent 7a0d613 commit 9690f4f
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion snap/hooks/post-refresh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

. "$SNAP/snap.env"
set_default_settings
reset_migrations_required

export CURRENT_SNAP_VERSION="$(get_snap_version_file)"

Expand Down Expand Up @@ -58,6 +57,7 @@ copy_config_as_daemon_user redis redis.conf
# Mastodon

. "$SNAP/mastodon.env"
reset_migrations_required

# NOTE: This is a fix for older versions and may be removed in the future
echo Set permissions on mastodon files and dirs
Expand Down
13 changes: 7 additions & 6 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,8 @@ parts:
- GEM_HOME: $CRAFT_PART_BUILD/vendor/ruby
- GEM_PATH: $GEM_HOME
- YARN_RC_FILENAME: $CRAFT_PART_BUILD/.yarnrc.yml
- YARN_CACHE_FOLDER: /tmp/yarn/cache
- YARN_CACHE_FOLDER: /tmp/yarn
- COREPACK_HOME: /tmp/corepack
- MASTODON_USE_LIBVIPS: "true"
# NOTE: workaround for current issue (see https://github.com/mastodon/mastodon/releases/tag/v4.3.0-beta.1)
- BUNDLE_BUILD__CHARLOCK_HOLMES: "--with-cxxflags=-std=c++17"
Expand All @@ -809,11 +810,11 @@ parts:
bundle config build.pg --with-pg-config=$CRAFT_STAGE/postgres/bin/pg_config
bundle install -j"$(nproc)"
mkdir -p $COREPACK_HOME $YARN_CACHE_FOLDER
corepack enable
corepack prepare --activate
mkdir -p $YARN_CACHE_FOLDER
yarn set version $YARN_VERSION
yarn install --immutable
corepack yarn set version $YARN_VERSION
corepack yarn install --immutable
npx update-browserslist-db@latest
yarn cache clean
npm cache clean --force
Expand Down Expand Up @@ -945,15 +946,15 @@ parts:
- GEM_HOME: $CRAFT_STAGE/mastodon/vendor/ruby
- GEM_PATH: $GEM_HOME
- YARN_RC_FILENAME: $CRAFT_STAGE/mastodon/.yarnrc.yml
- YARN_CACHE_FOLDER: /tmp/yarn/cache
- YARN_CACHE_FOLDER: /tmp/yarn
- COREPACK_HOME: /tmp/corepack
- OTP_SECRET: precompile_placeholder
- SECRET_KEY_BASE: precompile_placeholder
- ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY: precompile_placeholder
- ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT: precompile_placeholder
- ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY: precompile_placeholder
override-build: |
set -eux
mkdir -p $YARN_CACHE_FOLDER
cd $CRAFT_STAGE/mastodon
bundle exec rails assets:precompile
bundle exec rails log:clear tmp:clear
Expand Down
2 changes: 0 additions & 2 deletions src/mastodon/bin/recompile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@

. "$SNAP/mastodon.env"

mkdir_as_daemon_user "$YARN_CACHE_FOLDER"

echo "Recompile assets (this takes some time)"
mastodon_rails assets:precompile && mastodon_rails log:clear tmp:clear
2 changes: 1 addition & 1 deletion src/mastodon/bin/restore
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ echo Restore database
$SNAP/bin/psql.wrapper -f "$backup_dir/database.sql" template1 > /dev/null
if [ "$BACKUP_VERSION" != "$SNAP_VERSION" ]; then
echo Migrate database
$SNAP/bin/migrate > /dev/null
mastodon_db_migrate
fi

if [ -f "$backup_dir/redis.rdb" ]; then
Expand Down
2 changes: 1 addition & 1 deletion src/mastodon/bin/streaming
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ redis_waitready
export DB_POOL=25
export MALLOC_ARENA_MAX=2

mastodon_node streaming \
mastodon_streaming \
2>&1 | tee -a "$LOG_DIR/streaming.log"
3 changes: 3 additions & 0 deletions src/mastodon/bin/yarn
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@

. "$SNAP/mastodon.env"

mkdir_as_daemon_user "$COREPACK_HOME"
mkdir_as_daemon_user "$YARN_CACHE_FOLDER"

cd "$MASTODON_DIR" && corepack yarn "$@"
12 changes: 4 additions & 8 deletions src/mastodon/mastodon.env
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ export BUNDLE_RAKEFILE="$MASTODON_DIR/Rakefile"
export GEM_HOME="$MASTODON_DIR/vendor/ruby"
export GEM_PATH="$GEM_HOME"
export YARN_RC_FILENAME="$MASTODON_DIR/.yarnrc.yml"
export YARN_CACHE_FOLDER=/tmp/yarn/cache
export YARN_CACHE_FOLDER="$MASTODON_DIR/.cache/yarn"
export YARN_IGNORE_PATH=1
export COREPACK_HOME="$MASTODON_DIR/.cache/corepack"

export UPDATE_BACKUPS="$(snapctl get update.backups)"
export MEDIA_DIR="$(snapctl get media.dir)"
Expand Down Expand Up @@ -94,13 +95,8 @@ mastodon_rails() {
cd "$MASTODON_DIR" && run_as_daemon_user bundle exec rails "$@"
}

mastodon_node() {
cd "$MASTODON_DIR" && run_as_daemon_user node "$@"
}

mastodon_yarn() {
mkdir -p "$YARN_CACHE_FOLDER"
cd "$MASTODON_DIR" && run_as_daemon_user yarn "$@"
mastodon_streaming() {
cd "$MASTODON_DIR" && run_as_daemon_user node streaming "$@"
}

mastodon_sidekiq() {
Expand Down

0 comments on commit 9690f4f

Please sign in to comment.