From 1c33a9b72863789b736dc909c778f8df9af6544c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 12 May 2022 01:47:10 +0200 Subject: [PATCH] Switch to dedicated services --- check_process | 2 ++ conf/fab-manager-app.service | 19 ++++++++++++++ conf/fab-manager-worker.service | 18 +++++++++++++ conf/supervisor.service | 15 ----------- manifest.json | 2 +- scripts/_common.sh | 28 +++++++++++++++++--- scripts/backup | 9 ++----- scripts/change_url | 7 ++--- scripts/install | 45 ++++++++++++++++----------------- scripts/remove | 38 ++++++++-------------------- scripts/restore | 32 ++++++++++------------- scripts/upgrade | 43 +++++++++++++++++-------------- 12 files changed, 141 insertions(+), 117 deletions(-) create mode 100644 conf/fab-manager-app.service create mode 100644 conf/fab-manager-worker.service delete mode 100644 conf/supervisor.service diff --git a/check_process b/check_process index 25aab00..81fb967 100644 --- a/check_process +++ b/check_process @@ -16,6 +16,8 @@ upgrade=1 # 5.3.12~ynh1 upgrade=1 from_commit=b5305cfd99c5d0d356cf64e9d490e91d9b0cbae0 + # 5.3.12~ynh2 + upgrade=1 from_commit=de58f811f3bc27205ba2b1fbaed250253b1f13c8 backup_restore=1 multi_instance=0 port_already_use=0 diff --git a/conf/fab-manager-app.service b/conf/fab-manager-app.service new file mode 100644 index 0000000..ce6829c --- /dev/null +++ b/conf/fab-manager-app.service @@ -0,0 +1,19 @@ +[Unit] +Description=__APP__-app +After=network.target + +[Service] +Type=simple +User=__APP__ +WorkingDirectory=__FINALPATH__ +Environment="__LD_PRELOAD__" +Environment="__YNH_RUBY_LOAD_PATH__" +Environment="RAILS_ENV=production" +ExecStart=__FINALPATH__/bin/bundle exec rails s puma -p __PORT__ -b 0.0.0.0 +ExecReload=/bin/kill -SIGUSR1 $MAINPID +TimeoutSec=15 +Restart=always +StandardError=syslog + +[Install] +WantedBy=multi-user.target diff --git a/conf/fab-manager-worker.service b/conf/fab-manager-worker.service new file mode 100644 index 0000000..e137961 --- /dev/null +++ b/conf/fab-manager-worker.service @@ -0,0 +1,18 @@ +[Unit] +Description=__APP__-worker +After=network.target + +[Service] +Type=simple +User=__APP__ +WorkingDirectory=__FINALPATH__ +Environment="__LD_PRELOAD__" +Environment="__YNH_RUBY_LOAD_PATH__" +Environment="RAILS_ENV=production" +ExecStart=__FINALPATH__/bin/bundle exec sidekiq -C __FINALPATH__/config/sidekiq.yml +TimeoutSec=15 +Restart=always +StandardError=syslog + +[Install] +WantedBy=multi-user.target diff --git a/conf/supervisor.service b/conf/supervisor.service deleted file mode 100644 index 827f2a7..0000000 --- a/conf/supervisor.service +++ /dev/null @@ -1,15 +0,0 @@ -[program:__APP__-app] -command=__RBENV_ROOT__/versions/__APP__/bin/bundle exec rails s puma -p __PORT__ -b 0.0.0.0 -directory=__FINALPATH__/ -environment=RAILS_ENV=production,RACK_ENV=production,__YNH_NODE_LOAD_PATH__ -stderr_logfile=/var/log/supervisor/__APP__-app-stderr.log -stdout_logfile=/var/log/supervisor/__APP__-app-stdout.log -stdout_logfile_maxbytes=50MB -stdout_logfile_backups=100 - -[program:__APP__-worker] -command=__RBENV_ROOT__/versions/__APP__/bin/bundle exec sidekiq -C __FINALPATH__/config/sidekiq.yml -directory=__FINALPATH__/ -environment=RAILS_ENV=production,RACK_ENV=production,__YNH_NODE_LOAD_PATH__ -stderr_logfile=/var/log/supervisor/__APP__-worker-stderr.log -stdout_logfile=/var/log/supervisor/__APP__-worker-stdout.log diff --git a/manifest.json b/manifest.json index e567bda..5984148 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "Fab Lab management solution." }, - "version": "5.3.12~ynh2", + "version": "5.3.12~ynh3", "url": "https://www.fab-manager.com", "upstream": { "license": "AGPL-3.0-or-later", diff --git a/scripts/_common.sh b/scripts/_common.sh index 96fe933..ea216c7 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,13 +5,35 @@ #================================================= # dependencies used by the app -pkg_dependencies="ntp ntpdate tzdata curl git imagemagick supervisor tzdata libc-dev zlib1g-dev xz-utils postgresql postgresql-common postgresql-client libidn11-dev redis-server" +pkg_dependencies="ntp ntpdate tzdata curl git imagemagick tzdata libc-dev zlib1g-dev xz-utils postgresql postgresql-common postgresql-client libidn11-dev redis-server" build_pkg_dependencies="build-essential patch libpq-dev" -ruby_version=2.6 +ruby_version="2.6.9" -nodejs_version=12 +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/backup b/scripts/backup index ef8e638..7a3ed00 100755 --- a/scripts/backup +++ b/scripts/backup @@ -57,17 +57,12 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= - -ynh_backup --src_path="/etc/logrotate.d/$app" - #================================================= # BACKUP SYSTEMD #================================================= -ynh_backup --src_path="/etc/supervisor/conf.d/$app.conf" +ynh_backup --src_path="/etc/systemd/system/$app-app.service" +ynh_backup --src_path="/etc/systemd/system/$app-worker.service" #================================================= # BACKUP THE POSTGRESQL DATABASE diff --git a/scripts/change_url b/scripts/change_url index 961e259..b5d5d51 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -7,7 +7,6 @@ #================================================= source _common.sh -source ynh_supervisor source /usr/share/yunohost/helpers #================================================= @@ -79,7 +78,8 @@ fi #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_supervisor_action --service_name=$app --action="stop" --log_path="/var/log/supervisor/$app-app-stdout.log" +ynh_systemd_action --service_name=${app}-app --action="stop" --log_path=systemd --line_match="Stopped" +ynh_systemd_action --service_name=${app}-worker --action="stop" --log_path=systemd --line_match="Stopped" #================================================= # MODIFY URL IN NGINX CONF @@ -131,7 +131,8 @@ chown $app:$app "$final_path/config/secrets.yml" ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_supervisor_action --service_name=$app --action="start" --log_path="/var/log/supervisor/$app-app-stdout.log" --line_match="Listening on" +ynh_systemd_action --service_name=${app}-app --action="start" --log_path=systemd --line_match="Listening on" +ynh_systemd_action --service_name=${app}-worker --action="start" --log_path=systemd --line_match="Schedules Loaded" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index 58dd252..6bb2c44 100755 --- a/scripts/install +++ b/scripts/install @@ -8,7 +8,6 @@ source _common.sh source ynh_install_ruby__2 -source ynh_supervisor source /usr/share/yunohost/helpers #================================================= @@ -75,10 +74,10 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= ynh_script_progression --message="Installing dependencies..." -ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies -ynh_install_ruby --ruby_version=$ruby_version +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies +ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" #================================================= # CREATE DEDICATED USER @@ -86,22 +85,23 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # CREATE A POSTGRESQL DATABASE #================================================= ynh_script_progression --message="Creating a PostgreSQL database..." -ynh_psql_test_if_first_run db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH SUPERUSER;" --database="$db_name" ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database=$db_name ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;" --database=$db_name +ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH NOSUPERUSER;" --database="$db_name" db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= @@ -150,13 +150,18 @@ pushd $final_path ynh_exec_warn_less $ynh_gem install bundler ynh_exec_warn_less bin/bundle config --global frozen 1 ynh_exec_warn_less bin/bundle config set --local without 'development test doc' - ynh_exec_warn_less bin/bundle install --binstubs + ynh_exec_warn_less bin/bundle install + ynh_exec_warn_less bin/bundle binstubs --all ynh_use_nodejs ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean - ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production RACK_ENV=production $ynh_ruby_load_path bin/bundle exec rake db:migrate - ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production RACK_ENV=production $ynh_ruby_load_path bin/bundle exec rake db:seed ADMIN_EMAIL="$admin_mail" ADMIN_PASSWORD="$password" - ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production RACK_ENV=production $ynh_ruby_load_path bin/bundle exec rake assets:precompile + ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH SUPERUSER;" --database="$db_name" + ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake db:migrate + ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH NOSUPERUSER;" --database="$db_name" + ynh_replace_string --match_string="DateTime.current" --replace_string="DateTime.current - 1.days" --target_file="$final_path/db/seeds.rb" + ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake db:seed ADMIN_EMAIL="$admin_mail" ADMIN_PASSWORD="$password" + #ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production $ynh_ruby_load_path $ld_preload yarn install + #ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/webpack + ( ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake assets:precompile ) popd ynh_install_app_dependencies $pkg_dependencies @@ -183,32 +188,26 @@ chown -R $app:www-data "$datadir" ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config -ynh_add_supervisor_config +ynh_add_systemd_config --service="$app-app" --template="fab-manager-app.service" +ynh_add_systemd_config --service="$app-worker" --template="fab-manager-worker.service" #================================================= # GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." - -# Use logrotate to manage application logfile(s) -ynh_use_logrotate - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --log="/var/log/supervisor/$app-app-stdout.log /var/log/supervisor/$app-worker-stdout.log" +yunohost service add "$app-app" --description="$app app service" +yunohost service add "$app-worker" --description="$app worker service" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -# Start a systemd service -ynh_supervisor_action --service_name=$app --action="start" --log_path="/var/log/supervisor/$app-app-stdout.log" --line_match="Listening on" +ynh_systemd_action --service_name=${app}-app --action="start" --log_path=systemd --line_match="Listening on" +ynh_systemd_action --service_name=${app}-worker --action="start" --log_path=systemd --line_match="Schedules Loaded" #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index 9a85784..ec3d3a8 100755 --- a/scripts/remove +++ b/scripts/remove @@ -8,7 +8,6 @@ source _common.sh source ynh_install_ruby__2 -source ynh_supervisor source /usr/share/yunohost/helpers #================================================= @@ -19,7 +18,6 @@ ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) -port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) @@ -32,10 +30,16 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status $app >/dev/null +if ynh_exec_warn_less yunohost service status "$app-app" >/dev/null then - ynh_script_progression --message="Removing $app service integration..." - yunohost service remove $app + ynh_script_progression --message="Removing $app-app service integration..." + yunohost service remove "$app-app" +fi + +if ynh_exec_warn_less yunohost service status "$app-worker" >/dev/null +then + ynh_script_progression --message="Removing $app-worker service integration..." + yunohost service remove "$app-worker" fi #================================================= @@ -44,15 +48,8 @@ fi ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config -ynh_remove_supervisor_config - -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." - -# Remove the app-specific logrotate config -ynh_remove_logrotate +ynh_remove_systemd_config --service="$app-app" +ynh_remove_systemd_config --service="$app-worker" #================================================= # REMOVE THE POSTGRESQL DATABASE @@ -99,19 +96,6 @@ ynh_remove_ruby ynh_remove_nodejs ynh_remove_app_dependencies -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing various files..." - -# Remove the log files -ynh_secure_remove --file="/var/log/supervisor/$app-app-stderr.log" -ynh_secure_remove --file="/var/log/supervisor/$app-app-stdout.log" -ynh_secure_remove --file="/var/log/supervisor/$app-worker-stderr.log" -ynh_secure_remove --file="/var/log/supervisor/$app-worker-stdout.log" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 82b3a66..6890f55 100755 --- a/scripts/restore +++ b/scripts/restore @@ -9,7 +9,6 @@ # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source ../settings/scripts/ynh_install_ruby__2 -source ../settings/scripts/ynh_supervisor source /usr/share/yunohost/helpers #================================================= @@ -94,10 +93,10 @@ chown -R $app:www-data "$datadir" ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies -ynh_install_ruby --ruby_version=$ruby_version +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies +ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" #================================================= # RESTORE THE POSTGRESQL DATABASE @@ -124,11 +123,11 @@ pushd $final_path ynh_exec_warn_less $ynh_gem install bundler ynh_exec_warn_less bin/bundle config --global frozen 1 ynh_exec_warn_less bin/bundle config set --local without 'development test doc' - ynh_exec_warn_less bin/bundle install --binstubs + ynh_exec_warn_less bin/bundle install + ynh_exec_warn_less bin/bundle binstubs --all ynh_use_nodejs ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean - ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production RACK_ENV=production $ynh_ruby_load_path bin/bundle exec rake assets:precompile + ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake assets:precompile popd ynh_install_app_dependencies $pkg_dependencies @@ -139,30 +138,25 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= ynh_script_progression --message="Restoring the systemd configuration..." -ynh_restore_file --origin_path="/etc/supervisor/conf.d/$app.conf" -ynh_add_supervisor_config - -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +ynh_restore_file --origin_path="/etc/systemd/system/$app-app.service" +ynh_restore_file --origin_path="/etc/systemd/system/$app-worker.service" +systemctl enable "$app-app" "$app-worker" --quiet #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --log="/var/log/supervisor/$app-app-stdout.log /var/log/supervisor/$app-worker-stdout.log" +yunohost service add "$app-app" --description="$app app service" +yunohost service add "$app-worker" --description="$app worker service" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -# Start a systemd service -ynh_supervisor_action --service_name=$app --action="start" --log_path="/var/log/supervisor/$app-app-stdout.log" --line_match="Listening on" +ynh_systemd_action --service_name=${app}-app --action="start" --log_path=systemd --line_match="Listening on" +ynh_systemd_action --service_name=${app}-worker --action="start" --log_path=systemd --line_match="Schedules Loaded" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 6c9c7c6..8322922 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -59,7 +59,8 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_supervisor_action --service_name=$app --action="stop" --log_path="/var/log/supervisor/$app-app-stdout.log" +ynh_systemd_action --service_name=${app}-app --action="stop" --log_path=systemd --line_match="Stopped" +ynh_systemd_action --service_name=${app}-worker --action="stop" --log_path=systemd --line_match="Stopped" #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -73,6 +74,15 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi +ynh_remove_logrotate + +ynh_remove_supervisor_config + +ynh_secure_remove --file="/var/log/supervisor/$app-app-stderr.log" +ynh_secure_remove --file="/var/log/supervisor/$app-app-stdout.log" +ynh_secure_remove --file="/var/log/supervisor/$app-worker-stderr.log" +ynh_secure_remove --file="/var/log/supervisor/$app-worker-stdout.log" + #================================================= # CREATE DEDICATED USER #================================================= @@ -110,10 +120,10 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Upgrading dependencies..." -ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies -ynh_install_ruby --ruby_version=$ruby_version +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies +ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" #================================================= # SPECIFIC UPGRADE @@ -142,14 +152,14 @@ then ynh_exec_warn_less $ynh_gem install bundler ynh_exec_warn_less bin/bundle config --global frozen 1 ynh_exec_warn_less bin/bundle config set --local without 'development test doc' - ynh_exec_warn_less bin/bundle install --binstubs + ynh_exec_warn_less bin/bundle install + ynh_exec_warn_less bin/bundle binstubs --all ynh_use_nodejs ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH SUPERUSER;" --database="$db_name" - ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production RACK_ENV=production $ynh_ruby_load_path bin/bundle exec rake db:migrate + ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake db:migrate ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH NOSUPERUSER;" --database="$db_name" - ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production RACK_ENV=production $ynh_ruby_load_path bin/bundle exec rake assets:precompile + ynh_exec_warn_less ynh_exec_as $app env RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake assets:precompile popd fi @@ -162,31 +172,26 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config -ynh_add_supervisor_config +ynh_systemd_action --service_name=${app}-app --action="start" --log_path=systemd --line_match="Listening on" +ynh_systemd_action --service_name=${app}-worker --action="start" --log_path=systemd --line_match="Schedules Loaded" #================================================= # GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --log="/var/log/supervisor/$app-app-stdout.log /var/log/supervisor/$app-worker-stdout.log" +yunohost service add "$app-app" --description="$app app service" +yunohost service add "$app-worker" --description="$app worker service" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_supervisor_action --service_name=$app --action="start" --log_path="/var/log/supervisor/$app-app-stdout.log" --line_match="Listening on" +ynh_systemd_action --service_name=${app}-app --action="start" --log_path=systemd --line_match="Listening on" +ynh_systemd_action --service_name=${app}-worker --action="start" --log_path=systemd --line_match="Schedules Loaded" #================================================= # RELOAD NGINX