diff --git a/conf/jobs.service b/conf/jobs.service index 9f03cd5..0ecf68c 100644 --- a/conf/jobs.service +++ b/conf/jobs.service @@ -8,8 +8,9 @@ User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/ EnvironmentFile=__FINALPATH__/.env -ExecStart=/opt/rbenv/versions/__RUBY_VERSION__/bin/bundle exec rails runner bin/threaded.rb -StandardOutput=append:/var/log/__APP__/__APP__-jobs.log +Environment="__YNH_RUBY_LOAD_PATH__" +ExecStart=/opt/rbenv/versions/__APP__/bin/bundle exec rails runner bin/threaded.rb +StandardOutput=append:__FINALPATH__/log/__APP__-jobs.log StandardError=inherit [Install] diff --git a/conf/web.service b/conf/web.service index e3e72a4..740b6a9 100644 --- a/conf/web.service +++ b/conf/web.service @@ -8,8 +8,9 @@ User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/ EnvironmentFile=__FINALPATH__/.env -ExecStart=/opt/rbenv/versions/__RUBY_VERSION__/bin/bundle exec unicorn -c config/unicorn.rb -StandardOutput=append:/var/log/__APP__/__APP__-web.log +Environment="__YNH_RUBY_LOAD_PATH__" +ExecStart=/opt/rbenv/versions/__APP__/bin/bundle exec unicorn -c config/unicorn.rb +StandardOutput=append:__FINALPATH__/log/__APP__-web.log StandardError=inherit [Install] diff --git a/scripts/install b/scripts/install index 2b29fe1..52d4e66 100755 --- a/scripts/install +++ b/scripts/install @@ -138,8 +138,8 @@ pushd $final_path ynh_use_ruby cp config/unicorn.rb.example config/unicorn.rb chown -R $app:www-data "$final_path/config/unicorn.rb" - #ynh_gem update --system - ynh_gem install bundler foreman --no-document + ynh_gem update --system --no-document + ynh_gem install rake bundler foreman --no-document bundle install --deployment --without development test bundle exec rake db:create RAILS_ENV=production bundle exec rake db:migrate RAILS_ENV=production @@ -169,7 +169,7 @@ ynh_add_systemd_config --service="$app-jobs" --template="jobs.service" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add "$app-web" --log="/var/log/$app/$app-web.log" +yunohost service add "$app-web" --log="$final_path/log/unicorn.log" yunohost service add "$app-jobs" --log="/var/log/$app/$app-jobs.log" #================================================= @@ -178,7 +178,7 @@ yunohost service add "$app-jobs" --log="/var/log/$app/$app-jobs.log" ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/$app-web.log" --line_match="Started" +ynh_systemd_action --service_name="$app-web" --action="start" --log_path="$final_path/log/unicorn.log" --line_match="Started" ynh_systemd_action --service_name="$app-jobs" --action="start" --log_path="/var/log/$app/$app-jobs.log" --line_match="Started" #================================================= diff --git a/scripts/restore b/scripts/restore index 9a31b75..444539b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -82,7 +82,6 @@ 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_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE MYSQL DATABASE @@ -93,6 +92,25 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +#================================================= +# BUILD APP +#================================================= +ynh_script_progression --message="Building app..." + +pushd $final_path + ynh_use_ruby + ynh_gem update --system --no-document + ynh_gem install rake bundler foreman --no-document + bundle install --deployment --without development test + bundle exec rake assets:clean assets:precompile tmp:cache:clear RAILS_ENV=production +popd + +ynh_install_app_dependencies $pkg_dependencies + +chmod 750 "$final_path/public" +chmod -R o-rwx "$final_path/public" +chown -R $app:www-data "$final_path/public" + #================================================= # RESTORE SYSTEMD #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 66bfbdc..c61a1b0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -134,11 +134,11 @@ pushd $final_path ynh_use_ruby cp -f config/unicorn.rb.example config/unicorn.rb chown -R $app:www-data "$final_path/config/unicorn.rb" - #ynh_gem update --system - ynh_gem install bundler foreman --no-document + ynh_gem update --system --no-document + ynh_gem install rake bundler foreman --no-document bundle install --deployment --without development test bundle exec rake db:migrate RAILS_ENV=production - bundle exec rake assets:precompile RAILS_ENV=production + bundle exec rake assets:clean assets:precompile tmp:cache:clear RAILS_ENV=production popd ynh_install_app_dependencies $pkg_dependencies