Fix the services restarting every time the recipe is executed

* Manually send a restart action from the application_git resource
* Do not depend on application_ruby anymore
This commit is contained in:
Greg 2019-09-27 10:57:35 +02:00
parent 4b39ea60dd
commit 438c5ff72d
2 changed files with 9 additions and 12 deletions

View File

@ -10,8 +10,8 @@ depends "kosmos-nginx"
depends "kosmos-nodejs"
depends "kosmos-redis"
depends "poise-ruby-build"
depends "application_ruby"
depends "application_javascript"
depends "application"
depends "application_git"
depends "postgresql"
depends "kosmos-postgresql"
depends "backup"

View File

@ -128,7 +128,11 @@ application mastodon_path do
owner "mastodon"
group "mastodon"
environment "HOME" => mastodon_path
# Take care of application restarts manually, in the git resource
action_on_update false
environment "HOME" => mastodon_path,
"PATH" => "/opt/ruby_build/builds/#{ruby_version}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
ruby_runtime ruby_version do
provider :ruby_build
@ -140,6 +144,8 @@ application mastodon_path do
group mastodon_user
repository "https://gitea.kosmos.org/kosmos/mastodon.git"
revision "production"
# Restart services on deployments
notifies :restart, "application[#{mastodon_path}]", :delayed
end
mastodon_credentials = data_bag_item('credentials', 'mastodon')
@ -180,12 +186,6 @@ application mastodon_path do
command "yarn install --pure-lockfile"
end
rails do
migrate false
rails_env "production"
precompile_assets false # buggy, done manually below
end
execute 'rake db:migrate' do
environment "RAILS_ENV" => "production", "HOME" => mastodon_path
user mastodon_user
@ -194,9 +194,6 @@ application mastodon_path do
command "PATH=\"/opt/ruby_build/builds/#{ruby_version}/bin:$PATH\" bundle exec rake db:migrate"
end
# This is the only way I could find that makes compiling the assets
# successfully for now. application_ruby's precompile_assets crashes because
# it cannot find the bundled gems
execute 'rake assets:precompile' do
environment "RAILS_ENV" => "production", "HOME" => mastodon_path
user mastodon_user