From 29fcf08350770f7def5b503564333d00a8539038 Mon Sep 17 00:00:00 2001 From: Tagadda <36127788+Tagadda@users.noreply.github.com> Date: Sat, 12 Feb 2022 21:50:42 +0000 Subject: [PATCH] Workaround for bullseye --- conf/cron | 10 +++++----- conf/glitchsoc-sidekiq.service | 1 + conf/glitchsoc-web.service | 1 + scripts/_common.sh | 22 ++++++++++++++++++++++ scripts/install | 16 ++++++++-------- scripts/upgrade | 14 +++++++------- 6 files changed, 44 insertions(+), 20 deletions(-) diff --git a/conf/cron b/conf/cron index 710e7f0..c5f1af0 100644 --- a/conf/cron +++ b/conf/cron @@ -1,5 +1,5 @@ -@daily cd __FINAL_PATH__/live && sudo -u __APP__ __YNH_RUBY_LOAD_PATH__ RAILS_ENV=production bin/tootctl media remove -@monthly cd __FINAL_PATH__/live && sudo -u __APP__ __YNH_RUBY_LOAD_PATH__ RAILS_ENV=production bin/tootctl media remove-orphans -@monthly cd __FINAL_PATH__/live && sudo -u __APP__ __YNH_RUBY_LOAD_PATH__ RAILS_ENV=production bin/tootctl accounts cull -@monthly cd __FINAL_PATH__/live && sudo -u __APP__ __YNH_RUBY_LOAD_PATH__ RAILS_ENV=production bin/tootctl statuses remove -@monthly cd __FINAL_PATH__/live && sudo -u __APP__ __YNH_RUBY_LOAD_PATH__ RAILS_ENV=production bin/tootctl preview_cards remove +@daily cd __FINAL_PATH__/live && sudo -u __APP__ __YNH_RUBY_LOAD_PATH__ __LD_PRELOAD__ RAILS_ENV=production bin/tootctl media remove +@monthly cd __FINAL_PATH__/live && sudo -u __APP__ __YNH_RUBY_LOAD_PATH__ __LD_PRELOAD__ RAILS_ENV=production bin/tootctl media remove-orphans +@monthly cd __FINAL_PATH__/live && sudo -u __APP__ __YNH_RUBY_LOAD_PATH__ __LD_PRELOAD__ RAILS_ENV=production bin/tootctl accounts cull +@monthly cd __FINAL_PATH__/live && sudo -u __APP__ __YNH_RUBY_LOAD_PATH__ __LD_PRELOAD__ RAILS_ENV=production bin/tootctl statuses remove +@monthly cd __FINAL_PATH__/live && sudo -u __APP__ __YNH_RUBY_LOAD_PATH__ __LD_PRELOAD__ RAILS_ENV=production bin/tootctl preview_cards remove diff --git a/conf/glitchsoc-sidekiq.service b/conf/glitchsoc-sidekiq.service index f91b7b9..47fe663 100644 --- a/conf/glitchsoc-sidekiq.service +++ b/conf/glitchsoc-sidekiq.service @@ -6,6 +6,7 @@ After=network.target Type=simple User=__APP__ WorkingDirectory=__FINALPATH__/live +Environment="__LD_PRELOAD__" Environment="RAILS_ENV=production" Environment="DB_POOL=25" Environment="MALLOC_ARENA_MAX=2" diff --git a/conf/glitchsoc-web.service b/conf/glitchsoc-web.service index 24ab72a..42f5135 100644 --- a/conf/glitchsoc-web.service +++ b/conf/glitchsoc-web.service @@ -6,6 +6,7 @@ After=network.target Type=simple User=__APP__ WorkingDirectory=__FINALPATH__/live + Environment="RAILS_ENV=production" Environment="PORT=__PORT_WEB__" ExecStart=__RBENV_ROOT__/versions/__APP__/bin/bundle exec puma -C config/puma.rb diff --git a/scripts/_common.sh b/scripts/_common.sh index 8d24a71..ed70fab 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -13,6 +13,28 @@ RUBY_VERSION="3.0.3" NODEJS_VERSION="12" +# Workaround for Mastodon on Bullseye +# See https://github.com/mastodon/mastodon/issues/15751#issuecomment-873594463 +if [ "$(lsb_release --codename --short)" = "bullseye" ]; then + case $YNH_ARCH in + amd64) + arch="x86_64" + ;; + arm64) + arch="aarch64" + ;; + armel|armhf) + arch="arm" + ;; + i386) + arch="i386" + ;; + esac + ld_preload="LD_PRELOAD=/usr/lib/$arch-linux-gnu/libjemalloc.so" +else + ld_preload="" +fi + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 9950dfa..8e6dec7 100644 --- a/scripts/install +++ b/scripts/install @@ -224,17 +224,17 @@ ynh_add_systemd_config --service="$app-streaming" --template="glitchsoc-streamin ynh_script_progression --message="Installing Glitch-Soc..." --weight=30 pushd "$final_path/live" - ynh_exec_as $app $ynh_ruby_load_path bin/bundle config deployment 'true' - ynh_exec_as $app $ynh_ruby_load_path bin/bundle config without 'development test' - ynh_exec_as $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN) + ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config deployment 'true' + ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config without 'development test' + ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle install -j$(getconf _NPROCESSORS_ONLN) ynh_use_nodejs ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install --pure-lockfile echo "SAFETY_ASSURED=1">> $config - ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:setup --quiet - ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile --quiet - ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt - ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null - ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl accounts modify "$admin" --approve + ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails db:setup --quiet + ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:precompile --quiet + ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt + ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null + ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/tootctl accounts modify "$admin" --approve popd vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "$final_path/live/key.txt") diff --git a/scripts/upgrade b/scripts/upgrade index 692a6d2..d5d07e4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -337,15 +337,15 @@ then ynh_script_progression --message="Upgrading Glitch-Soc..." --weight=30 pushd "$final_path/live" - ynh_exec_as $app $ynh_ruby_load_path bin/bundle config deployment 'true' - ynh_exec_as $app $ynh_ruby_load_path bin/bundle config without 'development test' - ynh_exec_as $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN) + ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config deployment 'true' + ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config without 'development test' + ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle install -j$(getconf _NPROCESSORS_ONLN) ynh_use_nodejs ynh_exec_as $app $ynh_node_load_PATH yarn install --pure-lockfile - ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:clean - ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile - ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:migrate - ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl cache clear + ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:clean + ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:precompile + ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails db:migrate + ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/tootctl cache clear popd fi