diff --git a/conf/discourse-puma.service b/conf/discourse-puma.service index b129f7b..1a06240 100644 --- a/conf/discourse-puma.service +++ b/conf/discourse-puma.service @@ -11,6 +11,7 @@ Requires=discourse-sidekiq.service User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__ +Environment=__ADDITIONAL_ENV__ Environment=RAILS_ENV=production ExecStart=__RBENVROOT__/shims/bundle exec puma --config config/puma.rb -e production ExecStop=__RBENVROOT__/shims/bundle exec pumactl stop diff --git a/conf/nginx.conf b/conf/nginx.conf index d7dbd12..516893d 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,6 +1,12 @@ # maximum file upload size (keep up to date when changing the corresponding site setting) client_max_body_size 10m; + # extend timeouts + proxy_connect_timeout 600; + proxy_send_timeout 600; + proxy_read_timeout 600; + send_timeout 600; + # path to discourse's public directory set $public __FINALPATH__/public/; diff --git a/scripts/install b/scripts/install index 4e1d7f5..d3465d5 100644 --- a/scripts/install +++ b/scripts/install @@ -184,9 +184,22 @@ chown -R $app: $final_path gem install bundler # Install without documentation exec_as $app echo "gem: --no-ri --no-rdoc" >> "$final_path/.gemrc") +# If on ARM architecture, define the platform specificly to retrieve binaries +# for libv8 because it currently doesn't compile on ARM devices +if [ -n "$(uname -m | grep arm)" ] ; then + exec_login_as $app bundle config specific_platform arm-linux +fi # Install dependencies exec_login_as $app MAKEFLAGS=-j2 bundle install --jobs 2 --path vendor/bundle --with development +# On ARM architecture, replace bundled libpsl by system native libpsl +# because the provided binary isn't compatible +if [ -n "$(uname -m | grep arm)" ] ; then + (cd $final_path/vendor/bundle/ruby/*/gems/mini_suffix-*/vendor + rm libpsl.so + ln -s $(ldconfig -p | grep libpsl | awk 'END {print $NF}') libpsl.so) +fi + #================================================= # SETUP SIDEKIQ #================================================= @@ -255,6 +268,16 @@ patch -p1 < $YNH_CWD/../conf/ldap-auth-fix-subfolder.patch) ynh_replace_string "__RBENVROOT__" "$RBENV_ROOT" "../conf/discourse-puma.service" ynh_replace_string "__RBENVROOT__" "$RBENV_ROOT" "../conf/discourse-sidekiq.service" +# We assume for the moment that ARM devices are only dual core, so +# we restrict the number of workers to 2 (the default is 4) +if [ -n "$(uname -m | grep arm)" ] ; then + additional_env="NUM_WEBS=2" +else + additional_env="" +fi + +ynh_replace_string "__ADDITIONAL_ENV__" "$additional_env" "../conf/discourse-puma.service" + ynh_add_systemd_config $app-puma discourse-puma.service ynh_add_systemd_config $app-sidekiq discourse-sidekiq.service @@ -312,5 +335,4 @@ systemctl reload nginx # Wait for discourse-puma to be fully started # As discourse-sidekiq is a dependency, it is automatically started before ynh_check_starting_systemd "Use Ctrl-C to stop" "$app-puma" "120" -# Additional pause to avoid 502 errors in package_check after reinstall... -sleep 120s + diff --git a/scripts/restore b/scripts/restore index 7bea313..666fd00 100644 --- a/scripts/restore +++ b/scripts/restore @@ -129,5 +129,3 @@ ynh_check_starting_systemd "Use Ctrl-C to stop" "$app-puma" "120" systemctl reload nginx -# Additional pause to avoid 502 errors in package_check after reinstall... -sleep 120s diff --git a/scripts/upgrade b/scripts/upgrade index 9855e4a..7afbd68 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -164,6 +164,13 @@ gem install bundler exec_as $app echo "gem: --no-ri --no-rdoc" >> "$final_path/.gemrc" # Install dependencies exec_login_as $app bundle install --path vendor/bundle --with development) +# On ARM architecture, replace bundled libpsl by system native libpsl +# because the provided binary isn't compatible +if [ -n "$(uname -m | grep arm)" ] ; then + (cd $final_path/vendor/bundle/ruby/*/gems/mini_suffix-*/vendor + rm libpsl.so + ln -s $(ldconfig -p | grep libpsl | awk 'END {print $NF}') libpsl.so) +fi #================================================= # SETUP SIDEKIQ @@ -210,5 +217,4 @@ systemctl reload nginx # Wait for discourse-puma to be fully started # As discourse-sidekiq is a dependency, it is automatically started before ynh_check_starting_systemd "Use Ctrl-C to stop" "$app-puma" "120" -# Additional pause to avoid 502 errors in package_check after reinstall... -sleep 120s +