1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/discourse_ynh.git synced 2024-09-03 18:26:18 +02:00

Move sources into the discourse subdirectory

This commit is contained in:
Félix Piédallu 2024-08-29 12:47:51 +02:00
parent d3f0451113
commit 5dc2e9f19c
8 changed files with 103 additions and 88 deletions

View file

@ -8,7 +8,7 @@
send_timeout 600;
# path to discourse's public directory
set $public __INSTALL_DIR__/public/;
set $public __INSTALL_DIR__/discourse/public/;
# without weak etags we get zero benefit from etags on dynamically compressed content
# further more etags are based on the file in nginx not sha of data
@ -29,7 +29,7 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
alias __INSTALL_DIR__/public/ ;
alias __INSTALL_DIR__/discourse/public/ ;
proxy_hide_header ETag;
# auth_basic on;
@ -53,7 +53,7 @@
proxy_set_header X-Request-Start "t=${msec}";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock;
proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock;
break;
}
@ -99,7 +99,7 @@
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Sendfile-Type X-Accel-Redirect;
proxy_set_header X-Accel-Mapping __INSTALL_DIR__/public/=/downloads/;
proxy_set_header X-Accel-Mapping __INSTALL_DIR__/discourse/public/=/downloads/;
expires 1y;
more_set_headers "Cache-Control : public,immutable";
@ -120,7 +120,7 @@
try_files $uri =404;
}
proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock;
proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock;
break;
}
@ -131,8 +131,8 @@
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Sendfile-Type X-Accel-Redirect;
proxy_set_header X-Accel-Mapping __INSTALL_DIR__/public/=/downloads/;
proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock;
proxy_set_header X-Accel-Mapping __INSTALL_DIR__/discourse/public/=/downloads/;
proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock;
break;
}
@ -155,7 +155,7 @@
# proxy_cache one;
proxy_cache_valid 200 301 302 7d;
proxy_cache_valid any 1m;
proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock;
proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock;
break;
}
@ -189,7 +189,7 @@
proxy_set_header X-Forwarded-Proto https;
proxy_http_version 1.1;
proxy_buffering off;
proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock;
proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock;
break;
}
@ -199,7 +199,7 @@
location __PATH__/downloads/ {
internal;
alias __INSTALL_DIR__/public/ ;
alias __INSTALL_DIR__/discourse/public/ ;
}
location @__NAME__ {
@ -209,5 +209,5 @@
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock;
proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock;
}

View file

@ -8,14 +8,14 @@ After=postgresql.service
[Service]
User=__APP__
Group=__APP__
WorkingDirectory=__INSTALL_DIR__
WorkingDirectory=__INSTALL_DIR__/discourse
Environment=__ADDITIONAL_ENV__
Environment=RAILS_ENV=production
Environment=UNICORN_SIDEKIQS=1
Environment=LD_PRELOAD=__LIBJEMALLOC__
Environment=UNICORN_LISTENER=__INSTALL_DIR__/tmp/sockets/unicorn.sock
Environment=UNICORN_LISTENER=__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock
Environment="__YNH_RUBY_LOAD_PATH__"
ExecStart=__INSTALL_DIR__/bin/bundle exec unicorn --config config/unicorn.conf.rb -E production
ExecStart=__INSTALL_DIR__/discourse/bin/bundle exec unicorn --config config/unicorn.conf.rb -E production
Restart=always
RestartSec=10

View file

@ -66,7 +66,7 @@ When disabling Local Login and other authentication services, clicking the `Logi
### Installing plugins
```bash
cd /var/www/discourse
cd /var/www/discourse/discourse
sudo -i -u discourse RAILS_ENV=production bin/rake --trace plugin:install repo=https://github.com/discourse/discourse-solved (for example)
sudo -i -u discourse RAILS_ENV=production bin/rake --trace assets:precompile
systemctl restart discourse

View file

@ -65,7 +65,7 @@ Lors de la désactivation de la connexion locale et d'autres services d'authenti
### Installer des plugins
```bash
cd /var/www/discourse
cd /var/www/discourse/discourse
sudo -i -u discourse RAILS_ENV=production bin/rake --trace plugin:install repo=https://github.com/discourse/discourse-solved (for example)
sudo -i -u discourse RAILS_ENV=production bin/rake --trace assets:precompile
systemctl restart discourse

View file

@ -26,7 +26,7 @@ ynh_change_url_nginx_config
#=================================================
ynh_script_progression --message="Updating a config file..."
discourse_config_file="$install_dir/config/discourse.conf"
discourse_config_file="$install_dir/discourse/config/discourse.conf"
old_relative_url_root="${old_path%/}"
new_relative_url_root="${new_path%/}"
@ -46,14 +46,16 @@ UPDATE site_settings SET value = '${new_path}' WHERE name='long_polling_base_url
ynh_use_ruby
# Remap URLs in forum posts
ynh_exec_as "$app" --login RAILS_ENV=production bin/bundle exec script/discourse remap "$old_relative_url_root/uploads" "$new_relative_url_root/uploads" <<< "YES
ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec script/discourse remap "$old_relative_url_root/uploads" "$new_relative_url_root/uploads" <<< "YES
# "
pushd "$install_dir/discourse"
# Regenerate assets
ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/rake assets:precompile
# Regenerate all forum posts
ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/rake posts:rebake
popd
#=================================================
# START SYSTEMD SERVICE
@ -61,7 +63,7 @@ ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/rake post
ynh_script_progression --message="Starting $app's systemd service..."
# Start a systemd service
ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
#=================================================
# END OF SCRIPT

View file

@ -73,20 +73,20 @@ if dpkg --print-architecture | grep -q "arm"; then
fi
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
ynh_setup_source --dest_dir="$install_dir/discourse"
# Install LDAP plugin
ynh_setup_source --source_id=ldap-auth --dest_dir="$install_dir/plugins/discourse-ldap-auth"
ynh_setup_source --source_id=ldap-auth --dest_dir="$install_dir/discourse/plugins/discourse-ldap-auth"
# Add a pids and socket directory for the systemd script.
mkdir -p "$install_dir/tmp/pids"
mkdir -p "$install_dir/tmp/sockets"
mkdir -p "$install_dir/public/forum"
mkdir -p "$install_dir/discourse/tmp/pids"
mkdir -p "$install_dir/discourse/tmp/sockets"
mkdir -p "$install_dir/discourse/public/forum"
# Create specific folders and links for subfolder compatibility
# (see: https://meta.discourse.org/t/subfolder-support-with-docker/30507)
ln -s "$install_dir/public/uploads" "$install_dir/public/forum/uploads"
ln -s "$install_dir/public/backups" "$install_dir/public/forum/backups"
ln -s "$install_dir/discourse/public/uploads" "$install_dir/discourse/public/forum/uploads"
ln -s "$install_dir/discourse/public/backups" "$install_dir/discourse/public/forum/backups"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
@ -96,12 +96,12 @@ chown -R "$app:www-data" "$install_dir"
#=================================================
ynh_script_progression --message="Adding $app's configuration file..."
ynh_add_config --template="discourse_defaults.conf" --destination="$install_dir/config/discourse.conf"
ynh_add_config --template="secrets.yml" --destination="$install_dir/config/secrets.yml"
ynh_add_config --template="settings.yml" --destination="$install_dir/plugins/discourse-ldap-auth/config/settings.yml"
ynh_add_config --template="discourse_defaults.conf" --destination="$install_dir/discourse/config/discourse.conf"
ynh_add_config --template="secrets.yml" --destination="$install_dir/discourse/config/secrets.yml"
ynh_add_config --template="settings.yml" --destination="$install_dir/discourse/plugins/discourse-ldap-auth/config/settings.yml"
# Disable svgo worker
echo "svgo: false" | ynh_exec_as "$app" tee "$install_dir/.image_optim.yml" >/dev/null
echo "svgo: false" | ynh_exec_as "$app" tee "$install_dir/discourse/.image_optim.yml" >/dev/null
#=================================================
# SETUP UNICORN, A RUBY SERVER
@ -112,13 +112,13 @@ ynh_script_progression --message="Setting up Unicorn..."
# because the provided binary isn't compatible
if dpkg --print-architecture | grep -q "arm"; then
(
cd "$install_dir/vendor/bundle/ruby"/*/"gems/mini_suffix-*/vendor"
cd "$install_dir/discourse/vendor/bundle/ruby"/*/"gems/mini_suffix-*/vendor"
rm libpsl.so
ln -s "$(ldconfig -p | grep libpsl | awk 'END {print $NF}')" libpsl.so
)
fi
pushd "$install_dir"
pushd "$install_dir/discourse"
# Install bundler, a gems installer
ynh_gem install bundler
# Install without documentation
@ -128,16 +128,16 @@ pushd "$install_dir"
if dpkg --print-architecture | grep -q "arm"; then
# Define the platform specifically to retrieve binaries
# for libv8 because it currently doesn't compile on ARM devices
ynh_exec_as "$app" --login bin/bundle config specific_platform arm-linux
ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config specific_platform arm-linux
fi
# Install dependencies
ynh_exec_as "$app" --login bin/bundle config set path 'vendor/bundle'
ynh_exec_as "$app" --login bin/bundle config set without test development
ynh_exec_as "$app" --login MAKEFLAGS=-j2 bin/bundle install --jobs 2
ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config set path 'vendor/bundle'
ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config set without test development
ynh_exec_as "$app" --login MAKEFLAGS=-j2 "$install_dir/discourse/bin/bundle" install --jobs 2
popd
pushd "$install_dir"
pushd "$install_dir/discourse"
ynh_use_nodejs
ynh_npm install --location=global terser
ynh_npm install --location=global uglify-js
@ -150,8 +150,10 @@ popd
#=================================================
ynh_script_progression --message="Preparing the database..."
ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/bundle exec rake db:migrate
ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/bundle exec rake themes:update assets:precompile
pushd "$install_dir/discourse"
ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake db:migrate
ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake themes:update assets:precompile
popd
# Set default data (especially to have correct image URLs for subfolder install)
ynh_add_config --template="provisioning.sql" --destination="$install_dir/provisioning.sql"
@ -163,11 +165,13 @@ ynh_secure_remove --file="$install_dir/provisioning.sql"
#=================================================
ynh_script_progression --message="Creating Discourse admin user..."
pushd "$install_dir/discourse"
ynh_exec_as "$app" --login RAILS_ENV=production bin/rake admin:create <<< "$admin_mail
$admin_pwd
$admin_pwd
y
"
popd
#=================================================
# CONFIGURE PLUGINS
@ -177,7 +181,7 @@ ynh_script_progression --message="Configuring plugins..."
# Patch ldap-auth plugin dependency (omniauth-ldap) to fix it when using domain subfolder
# (Can only do that now because we are patching dependencies which have just been downloaded)
# Patch applied: https://github.com/omniauth/omniauth-ldap/pull/16
patch -p1 -d "$install_dir/plugins/discourse-ldap-auth/gems/$ruby_version/gems/omniauth-ldap"*/ \
patch -p1 -d "$install_dir/discourse/plugins/discourse-ldap-auth/gems/$ruby_version/gems/omniauth-ldap"*/ \
< "../conf/ldap-auth-fix-subfolder.patch"
#=================================================
@ -197,13 +201,13 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
additional_env="UNICORN_WORKERS=$unicorn_workers"
ynh_add_systemd_config
yunohost service add "$app" --log "$install_dir/log/unicorn.stderr.log" "$install_dir/log/unicorn.stdout.log" "$install_dir/log/production.log"
yunohost service add "$app" --log "$install_dir/discourse/log/unicorn.stderr.log" "$install_dir/discourse/log/unicorn.stdout.log" "$install_dir/discourse/log/production.log"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile="$install_dir/log/unicorn.stderr.log"
ynh_use_logrotate --logfile="$install_dir/log/unicorn.stdout.log"
ynh_use_logrotate --logfile="$install_dir/log/production.log"
ynh_use_logrotate --logfile="$install_dir/discourse/log/unicorn.stderr.log"
ynh_use_logrotate --logfile="$install_dir/discourse/log/unicorn.stdout.log"
ynh_use_logrotate --logfile="$install_dir/discourse/log/production.log"
#=================================================
# START SYSTEMD SERVICE
@ -211,7 +215,7 @@ ynh_use_logrotate --logfile="$install_dir/log/production.log"
ynh_script_progression --message="Starting $app's systemd service..."
# Start a systemd service
ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
#=================================================
# END OF SCRIPT

View file

@ -48,7 +48,7 @@ ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name"
#=================================================
ynh_script_progression --message="Reinstall Bundle Gem..."
pushd "$install_dir"
pushd "$install_dir/discourse"
ynh_gem install bundler
popd
@ -61,7 +61,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable "$app.service" --quiet
yunohost service add "$app" --log "$install_dir/log/unicorn.stderr.log" "$install_dir/log/unicorn.stdout.log" "$install_dir/log/production.log"
yunohost service add "$app" --log "$install_dir/discourse/log/unicorn.stderr.log" "$install_dir/discourse/log/unicorn.stdout.log" "$install_dir/discourse/log/production.log"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
@ -70,7 +70,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -32,7 +32,7 @@ ynh_maintenance_mode_ON
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name="$app" --action="stop" --log_path="$install_dir/log/unicorn.stderr.log"
ynh_systemd_action --service_name="$app" --action="stop" --log_path="$install_dir/discourse/log/unicorn.stderr.log"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
@ -51,6 +51,13 @@ if [ -z "$unicorn_workers" ]; then
ynh_app_setting_set --app="$app" --key="unicorn_workers" --value="$unicorn_workers"
fi
if [ -f "$install_dir/tmp/sockets/unicorn.sock" ]; then
# Move sources into the discourse subdir.
mkdir -p "$install_dir/__new__"
find "$install_dir" -mindepth 1 -maxdepth 1 -not -name "__new__" -print0 | xargs -0 mv -t "$install_dir/__new__"
mv "$install_dir/__new__" "$install_dir/discourse"
fi
#=================================================
# UPGRADING DEPENDENCIES
#=================================================
@ -75,35 +82,35 @@ if dpkg --print-architecture | grep -q "arm"; then
fi
# Small trick to backup non-core plugins
mv "$install_dir/plugins" "$install_dir/plugins_old"
mv "$install_dir/discourse/plugins" "$install_dir/discourse/plugins_old"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 \
ynh_setup_source --dest_dir="$install_dir/discourse" --full_replace=1 \
--keep="config/discourse.conf plugins_old public/uploads public/backups log"
# Restore all non-core plugins
for plugin_dir in "$install_dir/plugins_old"/*; do
for plugin_dir in "$install_dir/discourse/plugins_old"/*; do
plugin_name=$(basename "$plugin_dir")
if [ ! -d "$install_dir/plugins/$plugin_name" ]; then
mv "$plugin_dir" "$install_dir/plugins/$plugin_name"
if [ ! -d "$install_dir/discourse/plugins/$plugin_name" ]; then
mv "$plugin_dir" "$install_dir/discourse/plugins/$plugin_name"
fi
done
ynh_secure_remove --file="$install_dir/plugins_old"
ynh_secure_remove --file="$install_dir/discourse/plugins_old"
# Install LDAP plugin
ynh_setup_source --source_id=ldap-auth --dest_dir="$install_dir/plugins/discourse-ldap-auth" --full_replace=1 \
ynh_setup_source --source_id=ldap-auth --dest_dir="$install_dir/discourse/plugins/discourse-ldap-auth" --full_replace=1 \
--keep="config/settings.yml"
# Add a pids and socket directory for the systemd script.
mkdir -p "$install_dir/tmp/pids"
mkdir -p "$install_dir/tmp/sockets"
mkdir -p "$install_dir/public/forum"
mkdir -p "$install_dir/discourse/tmp/pids"
mkdir -p "$install_dir/discourse/tmp/sockets"
mkdir -p "$install_dir/discourse/public/forum"
# Create specific folders and links for subfolder compatibility
# (see: https://meta.discourse.org/t/subfolder-support-with-docker/30507)
ln -s "$install_dir/public/uploads" "$install_dir/public/forum/uploads"
ln -s "$install_dir/public/backups" "$install_dir/public/forum/backups"
ln -s "$install_dir/discourse/public/uploads" "$install_dir/discourse/public/forum/uploads"
ln -s "$install_dir/discourse/public/backups" "$install_dir/discourse/public/forum/backups"
# Set permissions to app files
chmod -R o-rwx "$install_dir"
@ -114,12 +121,12 @@ chown -R "$app:www-data" "$install_dir"
#=================================================
ynh_script_progression --message="Updating $app's config file..."
ynh_add_config --template="discourse_defaults.conf" --destination="$install_dir/config/discourse.conf"
ynh_add_config --template="secrets.yml" --destination="$install_dir/config/secrets.yml"
ynh_add_config --template="settings.yml" --destination="$install_dir/plugins/discourse-ldap-auth/config/settings.yml"
ynh_add_config --template="discourse_defaults.conf" --destination="$install_dir/discourse/config/discourse.conf"
ynh_add_config --template="secrets.yml" --destination="$install_dir/discourse/config/secrets.yml"
ynh_add_config --template="settings.yml" --destination="$install_dir/discourse/plugins/discourse-ldap-auth/config/settings.yml"
# Disable svgo worker
echo "svgo: false" | ynh_exec_as "$app" tee "$install_dir/.image_optim.yml" >/dev/null
echo "svgo: false" | ynh_exec_as "$app" tee "$install_dir/discourse/.image_optim.yml" >/dev/null
#=================================================
# SETUP UNICORN, A RUBY SERVER
@ -130,11 +137,11 @@ ynh_script_progression --message="Setting up Unicorn..."
ynh_use_ruby
# Make a backup of the original config file if modified
unicorn_config_file="$install_dir/config/unicorn.conf.rb"
unicorn_config_file="$install_dir/discourse/config/unicorn.conf.rb"
ynh_backup_if_checksum_is_different "$unicorn_config_file"
ynh_store_file_checksum --file="$unicorn_config_file"
pushd "$install_dir"
pushd "$install_dir/discourse"
# Install bundler, a gems installer
ynh_gem install bundler
# Install without documentation
@ -145,25 +152,25 @@ popd
if dpkg --print-architecture | grep -q "arm"; then
# Define the platform specifically to retrieve binaries
# for libv8 because it currently doesn't compile on ARM devices
ynh_exec_as "$app" --login bin/bundle config specific_platform arm-linux
ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config specific_platform arm-linux
fi
# Install dependencies
ynh_exec_as "$app" --login bin/bundle config set path 'vendor/bundle'
ynh_exec_as "$app" --login bin/bundle config set with 'development'
ynh_exec_as "$app" --login MAKEFLAGS=-j2 bin/bundle install --jobs 2
ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config set path 'vendor/bundle'
ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config set with 'development'
ynh_exec_as "$app" --login MAKEFLAGS=-j2 "$install_dir/discourse/bin/bundle" install --jobs 2
# On ARM architecture, replace bundled libpsl by system native libpsl
# because the provided binary isn't compatible
if dpkg --print-architecture | grep -q "arm"; then
(
cd "$install_dir/vendor/bundle/ruby"/*/"gems/mini_suffix-*/vendor"
cd "$install_dir/discourse/vendor/bundle/ruby"/*/"gems/mini_suffix-*/vendor"
rm libpsl.so
ln -s "$(ldconfig -p | grep libpsl | awk 'END {print $NF}')" libpsl.so
)
fi
pushd "$install_dir"
pushd "$install_dir/discourse"
ynh_use_nodejs
ynh_npm install --location=global terser
ynh_npm install --location=global uglify-js
@ -177,8 +184,10 @@ popd
ynh_script_progression --message="Preparing the database..."
ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/bundle exec rake db:migrate
ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/bundle exec rake themes:update assets:precompile
pushd "$install_dir/discourse"
ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake db:migrate
ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake themes:update assets:precompile
popd
#=================================================
# CONFIGURE PLUGINS
@ -188,7 +197,7 @@ ynh_script_progression --message="Configuring plugins..."
# Patch ldap-auth plugin dependency (omniauth-ldap) to fix it when using domain subfolder
# (Can only do that now because we are patching dependencies which have just been downloaded)
# Patch applied: https://github.com/omniauth/omniauth-ldap/pull/16
patch -p1 -d "$install_dir/plugins/discourse-ldap-auth/gems/$ruby_version/gems/omniauth-ldap"*/ \
patch -p1 -d "$install_dir/discourse/plugins/discourse-ldap-auth/gems/$ruby_version/gems/omniauth-ldap"*/ \
< "../conf/ldap-auth-fix-subfolder.patch"
#=================================================
@ -208,19 +217,19 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
additional_env="UNICORN_WORKERS=$unicorn_workers"
ynh_add_systemd_config
yunohost service add "$app" --log "$install_dir/log/unicorn.stderr.log" "$install_dir/log/unicorn.stdout.log" "$install_dir/log/production.log"
yunohost service add "$app" --log "$install_dir/discourse/log/unicorn.stderr.log" "$install_dir/discourse/log/unicorn.stdout.log" "$install_dir/discourse/log/production.log"
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --logfile="$install_dir/log/unicorn.stderr.log"
ynh_use_logrotate --logfile="$install_dir/log/unicorn.stdout.log"
ynh_use_logrotate --logfile="$install_dir/log/production.log"
ynh_use_logrotate --logfile="$install_dir/discourse/log/unicorn.stderr.log"
ynh_use_logrotate --logfile="$install_dir/discourse/log/unicorn.stdout.log"
ynh_use_logrotate --logfile="$install_dir/discourse/log/production.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting $app's systemd service..."
ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
#=================================================
# DISABLE MAINTENANCE MODE