mirror of
https://github.com/YunoHost-Apps/mastodon_ynh.git
synced 2024-09-03 19:46:02 +02:00
improve ruby management
This commit is contained in:
parent
c19e9dfbcf
commit
c4da166afb
8 changed files with 34 additions and 24 deletions
|
@ -1,2 +1,2 @@
|
|||
RAILS_ENV=production
|
||||
@daily cd __FINAL__PATH__/live && /opt/rbenv/versions/2.6.6/bin/bundle exec rake __USER__:media:remove_remote
|
||||
@daily cd __FINAL__PATH__/live && __RBENVROOT__/bin/bundle exec rake __USER__:media:remove_remote
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
Environment="RAILS_ENV=production"
|
||||
Environment="DB_POOL=25"
|
||||
Environment="MALLOC_ARENA_MAX=2"
|
||||
ExecStart=/opt/rbenv/versions/2.6.6/bin/bundle exec sidekiq -c 25
|
||||
ExecStart=__RBENVROOT__/shims/bundle exec sidekiq -c 25
|
||||
TimeoutSec=15
|
||||
Restart=always
|
||||
StandardError=syslog
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
WorkingDirectory=__FINALPATH__/live
|
||||
Environment="RAILS_ENV=production"
|
||||
Environment="PORT=__PORT_WEB__"
|
||||
ExecStart=/opt/rbenv/versions/2.6.6/bin/bundle exec puma -C config/puma.rb
|
||||
ExecStart=__RBENVROOT__/shims/bundle exec puma -C config/puma.rb
|
||||
ExecReload=/bin/kill -SIGUSR1 $MAINPID
|
||||
TimeoutSec=15
|
||||
Restart=always
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3|libgdbm6 libgdbm-dev redis-server redis-tools postgresql postgresql-contrib libidn11-dev libicu-dev libjemalloc-dev curl apt-transport-https"
|
||||
RUBY_VERSION="2.6.6"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
|
|
|
@ -146,13 +146,11 @@ ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
|||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# INSTALLING RUBY AND BUNDLER
|
||||
# INSTALLING RUBY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Ruby..." --weight=424
|
||||
|
||||
ynh_install_ruby --ruby_version=2.6.6
|
||||
/opt/rbenv/versions/2.6.6/bin/gem update --system
|
||||
/opt/rbenv/versions/2.6.6/bin/gem install bundler:1.17.3 --no-document
|
||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
|
@ -190,12 +188,17 @@ chown -R "$app": "$final_path"
|
|||
|
||||
pushd "$final_path/live"
|
||||
ynh_use_nodejs
|
||||
sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.6/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test
|
||||
gem update --system
|
||||
gem install bundler --no-document
|
||||
|
||||
sudo -u "$app" env PATH=$PATH bundle config set deployment 'true'
|
||||
sudo -u "$app" env PATH=$PATH bundle config set without 'development test'
|
||||
sudo -u "$app" env PATH=$PATH bundle install -j$(getconf _NPROCESSORS_ONLN)
|
||||
sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile
|
||||
sudo -u "$app" echo "SAFETY_ASSURED=1">> .env.production
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rails db:setup --quiet
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rails assets:precompile --quiet
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production bundle exec rails db:setup --quiet
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production bundle exec rails assets:precompile --quiet
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production bundle exec rake mastodon:webpush:generate_vapid_key > key.txt
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > acc.txt
|
||||
popd
|
||||
|
||||
|
@ -219,6 +222,7 @@ ynh_secure_remove --file="$final_path/live/key.txt"
|
|||
ynh_script_progression --message="Setuping a cron job for removing cache..." --weight=1
|
||||
|
||||
ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron"
|
||||
ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/cron"
|
||||
ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/cron"
|
||||
sudo cp -f ../conf/cron /etc/cron.d/$app
|
||||
|
||||
|
@ -229,6 +233,8 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=5
|
|||
|
||||
# Create a dedicated systemd config
|
||||
ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service"
|
||||
ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/mastodon-web.service"
|
||||
ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/mastodon-sidekiq.service"
|
||||
ynh_replace_string --match_string="__PORT_STREAM__" --replace_string="$port_stream" --target_file="../conf/mastodon-streaming.service"
|
||||
ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/mastodon-streaming.service"
|
||||
ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service"
|
||||
|
|
|
@ -110,13 +110,11 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||
|
||||
#=================================================
|
||||
# INSTALLING RUBY AND BUNDLER
|
||||
# INSTALLING RUBY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Ruby..." --weight=393
|
||||
|
||||
ynh_install_ruby --ruby_version=2.6.6
|
||||
/opt/rbenv/versions/2.6.6/bin/gem update --system
|
||||
/opt/rbenv/versions/2.6.6/bin/gem install bundler:1.17.3 --no-document
|
||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
|
|
|
@ -240,13 +240,11 @@ ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
|||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# INSTALLING RUBY AND BUNDLER
|
||||
# INSTALLING RUBY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Ruby..." --weight=424
|
||||
|
||||
ynh_install_ruby --ruby_version=2.6.6
|
||||
/opt/rbenv/versions/2.6.6/bin/gem update --system
|
||||
/opt/rbenv/versions/2.6.6/bin/gem install bundler:1.17.3 --no-document
|
||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
|
@ -282,11 +280,15 @@ chown -R "$app": "$final_path"
|
|||
|
||||
pushd "$final_path/live"
|
||||
ynh_use_nodejs
|
||||
sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.6/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test
|
||||
gem update --system
|
||||
gem install bundler --no-document
|
||||
sudo -u "$app" env PATH=$PATH bundle config set deployment 'true'
|
||||
sudo -u "$app" env PATH=$PATH bundle config set without 'development test'
|
||||
sudo -u "$app" env PATH=$PATH bundle install -j$(getconf _NPROCESSORS_ONLN)
|
||||
sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rails assets:clean
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rails assets:precompile
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rails db:migrate
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production bundle exec rails assets:clean
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production bundle exec rails assets:precompile
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production bundle exec rails db:migrate
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl cache clear
|
||||
popd
|
||||
|
||||
|
@ -311,6 +313,7 @@ ynh_store_file_checksum --file="${final_path}/live/.env.production"
|
|||
ynh_script_progression --message="Setuping a cron job for removing cache..." --weight=1
|
||||
|
||||
ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron"
|
||||
ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/cron"
|
||||
ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/cron"
|
||||
sudo cp -f ../conf/cron /etc/cron.d/$app
|
||||
|
||||
|
@ -321,6 +324,8 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
|||
|
||||
# Create a dedicated systemd config
|
||||
ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service"
|
||||
ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/mastodon-web.service"
|
||||
ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/mastodon-sidekiq.service"
|
||||
ynh_replace_string --match_string="__PORT_STREAM__" --replace_string="$port_stream" --target_file="../conf/mastodon-streaming.service"
|
||||
ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/mastodon-streaming.service"
|
||||
ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service"
|
||||
|
|
|
@ -94,7 +94,7 @@ ynh_install_ruby () {
|
|||
test -x /usr/bin/ruby_rbenv && mv /usr/bin/ruby_rbenv /usr/bin/ruby
|
||||
|
||||
# Install the requested version of ruby
|
||||
CONFIGURE_OPTS="--disable-install-doc" MAKE_OPTS="-j2" rbenv install --skip-existing $ruby_version
|
||||
CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $ruby_version
|
||||
|
||||
# Store the ID of this app and the version of ruby requested for it
|
||||
echo "$YNH_APP_ID:$ruby_version" | tee --append "$rbenv_install_dir/ynh_app_version"
|
||||
|
|
Loading…
Add table
Reference in a new issue