From 1c33a9b72863789b736dc909c778f8df9af6544c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 12 May 2022 01:47:10 +0200 Subject: [PATCH 01/12] 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 From 58a4fa13158d1ae7b5c81ff39c318b991c4af88e Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 11 May 2022 23:47:15 +0000 Subject: [PATCH 02/12] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0971c7f..b0658c0 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Fab Lab management solution. -**Shipped version:** 5.3.12~ynh2 +**Shipped version:** 5.3.12~ynh3 **Demo:** https://www.fab-manager.com/fr/demo diff --git a/README_fr.md b/README_fr.md index 3300c6f..a65d4e9 100644 --- a/README_fr.md +++ b/README_fr.md @@ -13,7 +13,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour -**Version incluse :** 5.3.12~ynh2 +**Version incluse :** 5.3.12~ynh3 **Démo :** https://www.fab-manager.com/fr/demo From e7e868c83242f30cf886ece92027d4f99374910d Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Fri, 13 May 2022 06:12:34 +0000 Subject: [PATCH 03/12] Upgrade to v5.4.0 --- conf/app.src | 4 ++-- manifest.json | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/conf/app.src b/conf/app.src index 9b39dce..281baa3 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/sleede/fab-manager/archive/refs/tags/v5.3.12.tar.gz -SOURCE_SUM=317046f8ef64745a50ed72df23e8b0060de0d4227fbc011ee9d837fca0527aa8 +SOURCE_URL=https://api.github.com/repos/sleede/fab-manager/tarball/v5.4.0 +SOURCE_SUM=3cc9ca5e26678c80e7169fe295d77f9dd3e0e6b9656f78d1e5e469f94104864d SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index e567bda..e49893c 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "Fab Lab management solution." }, - "version": "5.3.12~ynh2", + "version": "5.4.0~ynh1", "url": "https://www.fab-manager.com", "upstream": { "license": "AGPL-3.0-or-later", @@ -44,7 +44,10 @@ "en": "Choose the application language", "fr": "Choisissez la langue de l'application" }, - "choices": ["fr", "en"], + "choices": [ + "fr", + "en" + ], "default": "fr" }, { From 204647aa89393094b5f4839b3f5b3d72732e089d Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Fri, 13 May 2022 06:12:38 +0000 Subject: [PATCH 04/12] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0971c7f..9298d37 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Fab Lab management solution. -**Shipped version:** 5.3.12~ynh2 +**Shipped version:** 5.4.0~ynh1 **Demo:** https://www.fab-manager.com/fr/demo diff --git a/README_fr.md b/README_fr.md index 3300c6f..735826f 100644 --- a/README_fr.md +++ b/README_fr.md @@ -13,7 +13,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour -**Version incluse :** 5.3.12~ynh2 +**Version incluse :** 5.4.0~ynh1 **Démo :** https://www.fab-manager.com/fr/demo From d3010e9be232996a451bab3ec0b7e8a2eed633f6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 14 May 2022 14:23:30 +0200 Subject: [PATCH 05/12] Fix upgrade --- scripts/upgrade | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 8322922..717b03b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -74,6 +74,12 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi +if ynh_exec_warn_less yunohost service status $app >/dev/null +then + ynh_script_progression --message="Removing $app service integration..." + yunohost service remove $app +fi + ynh_remove_logrotate ynh_remove_supervisor_config @@ -172,8 +178,8 @@ 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_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" +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 From ff317a6d9b1593c4aca82cf89723585f9a21f07c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 15 May 2022 12:09:45 +0200 Subject: [PATCH 06/12] Fix missing $ynh_ruby_load_path --- scripts/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 717b03b..f2cf621 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -130,6 +130,8 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dep ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version 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" +ynh_use_ruby +ynh_use_nodejs #================================================= # SPECIFIC UPGRADE @@ -154,13 +156,11 @@ ynh_script_progression --message="Building app..." if [ "$upgrade_type" == "UPGRADE_APP" ] then pushd $final_path - ynh_use_ruby 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 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_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 From 50b1f0617e088bfd7e19c47e883792b80e5650a7 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 16 May 2022 12:34:49 +0200 Subject: [PATCH 07/12] Update upgrade --- scripts/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index f2cf621..717b03b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -130,8 +130,6 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dep ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version 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" -ynh_use_ruby -ynh_use_nodejs #================================================= # SPECIFIC UPGRADE @@ -156,11 +154,13 @@ ynh_script_progression --message="Building app..." if [ "$upgrade_type" == "UPGRADE_APP" ] then pushd $final_path + ynh_use_ruby 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 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_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 From 5e3247f9d4686ca8a7df1255dfa9a02d7ef0fb9e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 16 May 2022 12:37:33 +0200 Subject: [PATCH 08/12] Update DESCRIPTION.md --- doc/DESCRIPTION.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index e69de29..3d6b88a 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +Fab-manager is the Fab Lab management solution. It provides a comprehensive, web-based, open-source tool to simplify your administrative tasks, and document your marker's projects. From ca72b600ffdc79459b9fc71c22ea2a4714e3cc61 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 16 May 2022 10:37:37 +0000 Subject: [PATCH 09/12] Auto-update README --- README.md | 3 ++- README_fr.md | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9298d37..3560a7d 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Fab Lab management solution. +Fab-manager is the Fab Lab management solution. It provides a comprehensive, web-based, open-source tool to simplify your administrative tasks, and document your marker's projects. + **Shipped version:** 5.4.0~ynh1 diff --git a/README_fr.md b/README_fr.md index 735826f..3b9364f 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,6 +11,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble +Fab-manager is the Fab Lab management solution. It provides a comprehensive, web-based, open-source tool to simplify your administrative tasks, and document your marker's projects. **Version incluse :** 5.4.0~ynh1 From 3468fe25994542ceec3156af69d95ba72a68e05d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 20 May 2022 21:22:29 +0200 Subject: [PATCH 10/12] Fix pre-existing pid file --- conf/fab-manager-app.service | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/fab-manager-app.service b/conf/fab-manager-app.service index ce6829c..d7e7ab0 100644 --- a/conf/fab-manager-app.service +++ b/conf/fab-manager-app.service @@ -9,6 +9,7 @@ WorkingDirectory=__FINALPATH__ Environment="__LD_PRELOAD__" Environment="__YNH_RUBY_LOAD_PATH__" Environment="RAILS_ENV=production" +ExecStartPre=-/bin/bash -c 'rm -f __FINAL_PARH__/tmp/pids/server.pid' ExecStart=__FINALPATH__/bin/bundle exec rails s puma -p __PORT__ -b 0.0.0.0 ExecReload=/bin/kill -SIGUSR1 $MAINPID TimeoutSec=15 From c83b2bf0502da0f10b886dd951e0cb652a1d5223 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 23 May 2022 19:46:29 +0200 Subject: [PATCH 11/12] Typo --- conf/fab-manager-app.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/fab-manager-app.service b/conf/fab-manager-app.service index d7e7ab0..faec88f 100644 --- a/conf/fab-manager-app.service +++ b/conf/fab-manager-app.service @@ -9,7 +9,7 @@ WorkingDirectory=__FINALPATH__ Environment="__LD_PRELOAD__" Environment="__YNH_RUBY_LOAD_PATH__" Environment="RAILS_ENV=production" -ExecStartPre=-/bin/bash -c 'rm -f __FINAL_PARH__/tmp/pids/server.pid' +ExecStartPre=-/bin/bash -c 'rm -f __FINAL_PATH__/tmp/pids/server.pid' ExecStart=__FINALPATH__/bin/bundle exec rails s puma -p __PORT__ -b 0.0.0.0 ExecReload=/bin/kill -SIGUSR1 $MAINPID TimeoutSec=15 From 90d3f6ad647492c7c403dcb9fa87d459e9767a57 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 25 May 2022 06:28:30 +0000 Subject: [PATCH 12/12] Auto-update README --- README.md | 19 ++++++++++--------- README_fr.md | 25 +++++++++++++++---------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 3560a7d..52698e8 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ It shall NOT be edited by hand. # Fab-manager for YunoHost -[![Integration level](https://dash.yunohost.org/integration/fab-manager.svg)](https://dash.yunohost.org/appci/app/fab-manager) ![](https://ci-apps.yunohost.org/ci/badges/fab-manager.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/fab-manager.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/fab-manager.svg)](https://dash.yunohost.org/appci/app/fab-manager) ![Working status](https://ci-apps.yunohost.org/ci/badges/fab-manager.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/fab-manager.maintain.svg) [![Install Fab-manager with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=fab-manager) *[Lire ce readme en français.](./README_fr.md)* @@ -24,25 +24,26 @@ Fab-manager is the Fab Lab management solution. It provides a comprehensive, web ## Screenshots -![](./doc/screenshots/dashboard-mockup.webp) +![Screenshot of Fab-manager](./doc/screenshots/dashboard-mockup.webp) ## Documentation and resources -* Official app website: https://www.fab-manager.com -* Official admin documentation: http://doc.fab.mn -* Upstream app code repository: https://github.com/sleede/fab-manager -* YunoHost documentation for this app: https://yunohost.org/app_fab-manager -* Report a bug: https://github.com/YunoHost-Apps/fab-manager_ynh/issues +* Official app website: +* Official admin documentation: +* Upstream app code repository: +* YunoHost documentation for this app: +* Report a bug: ## Developer info Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/fab-manager_ynh/tree/testing). To try the testing branch, please proceed like that. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/fab-manager_ynh/tree/testing --debug or sudo yunohost app upgrade fab-manager -u https://github.com/YunoHost-Apps/fab-manager_ynh/tree/testing --debug ``` -**More info regarding app packaging:** https://yunohost.org/packaging_apps \ No newline at end of file +**More info regarding app packaging:** diff --git a/README_fr.md b/README_fr.md index 3b9364f..dfd9c9b 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,10 +1,14 @@ + + # Fab-manager pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/fab-manager.svg)](https://dash.yunohost.org/appci/app/fab-manager) ![](https://ci-apps.yunohost.org/ci/badges/fab-manager.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/fab-manager.maintain.svg) +[![Niveau d'intégration](https://dash.yunohost.org/integration/fab-manager.svg)](https://dash.yunohost.org/appci/app/fab-manager) ![Status du fonctionnement](https://ci-apps.yunohost.org/ci/badges/fab-manager.status.svg) ![Status de maintenance](https://ci-apps.yunohost.org/ci/badges/fab-manager.maintain.svg) [![Installer Fab-manager avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=fab-manager) *[Read this readme in english.](./README.md)* -*[Lire ce readme en français.](./README_fr.md)* > *Ce package vous permet d'installer Fab-manager rapidement et simplement sur un serveur YunoHost. Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* @@ -20,25 +24,26 @@ Fab-manager is the Fab Lab management solution. It provides a comprehensive, web ## Captures d'écran -![](./doc/screenshots/dashboard-mockup.webp) +![Capture d'écran de Fab-manager](./doc/screenshots/dashboard-mockup.webp) ## Documentations et ressources -* Site officiel de l'app : https://www.fab-manager.com -* Documentation officielle de l'admin : http://doc.fab.mn -* Dépôt de code officiel de l'app : https://github.com/sleede/fab-manager -* Documentation YunoHost pour cette app : https://yunohost.org/app_fab-manager -* Signaler un bug : https://github.com/YunoHost-Apps/fab-manager_ynh/issues +* Site officiel de l'app : +* Documentation officielle de l'admin : +* Dépôt de code officiel de l'app : +* Documentation YunoHost pour cette app : +* Signaler un bug : ## Informations pour les développeurs Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/fab-manager_ynh/tree/testing). Pour essayer la branche testing, procédez comme suit. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/fab-manager_ynh/tree/testing --debug ou sudo yunohost app upgrade fab-manager -u https://github.com/YunoHost-Apps/fab-manager_ynh/tree/testing --debug ``` -**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps \ No newline at end of file +**Plus d'infos sur le packaging d'applications :**