Commit 33449edd authored by Héctor Orón Martínez's avatar Héctor Orón Martínez

Merge branch 'fix-delayed-jobs' into 'debian/master'

Fix delayed jobs

See merge request !27
parents 9d149e5f 4c390a3d
......@@ -21,8 +21,11 @@ open-build-service (2.9.4-3) UNRELEASED; urgency=medium
* debian/rake-tasks.sh: update migration task to restart all OBS related
services.
* debian/README.Debian: add instructions on how to upgrade an exitent instance
* debian/rake-tasks.sh: stop all running processes from the old installation
* debian/obs-api.postrm: stop obsapi systemd services
* debian/osb-api.prerm: stop the new obsapi systemd unit files
-- Lucas Kanashiro <kanashiro@debian.org> Tue, 09 Apr 2019 15:36:09 -0300
-- Lucas Kanashiro <kanashiro@debian.org> Fri, 12 Apr 2019 16:01:19 -0300
open-build-service (2.9.4-2) unstable; urgency=medium
......
......@@ -37,6 +37,18 @@ reload_apache()
fi
}
stop_obsapi()
{
deb-systemd-invoke stop obsapi-clockwork.service >/dev/null || true
deb-systemd-invoke stop obsapi-delayedjob-queue-consistency_check.service >/dev/null || true
deb-systemd-invoke stop obsapi-delayedjob-queue-default.service >/dev/null || true
deb-systemd-invoke stop obsapi-delayedjob-queue-issuetracking.service >/dev/null || true
deb-systemd-invoke stop obsapi-delayedjob-queue-mailers.service >/dev/null || true
deb-systemd-invoke stop obsapi-delayedjob-queue-project_log_rotate.service >/dev/null || true
deb-systemd-invoke stop obsapi-delayedjob-queue-quick.service >/dev/null || true
deb-systemd-invoke stop obsapi-delayedjob-queue-releasetracking.service >/dev/null || true
}
if [ "$1" = "purge" ]; then
# ucf follows the symlink under /etc
#rm -f /etc/obs/api/config/database.yml
......@@ -72,6 +84,11 @@ if [ "$1" = "purge" ]; then
delgroup --system --quiet obsapi || true
# Restart Apache to really unload obs.conf
reload_apache restart
stop_obsapi
elif [ "$1" = "upgrade" ]; then
stop_obsapi
fi
#DEBHELPER#
......@@ -9,7 +9,15 @@ case "$1" in
. /usr/share/dbconfig-common/dpkg/prerm.mysql
dbc_go obs-api $@
fi
deb-systemd-invoke stop obsapidelayed >/dev/null || true
deb-systemd-invoke stop obsapi-clockwork.service >/dev/null || true
deb-systemd-invoke stop obsapi-delayedjob-queue-consistency_check.service >/dev/null || true
deb-systemd-invoke stop obsapi-delayedjob-queue-default.service >/dev/null || true
deb-systemd-invoke stop obsapi-delayedjob-queue-issuetracking.service >/dev/null || true
deb-systemd-invoke stop obsapi-delayedjob-queue-mailers.service >/dev/null || true
deb-systemd-invoke stop obsapi-delayedjob-queue-project_log_rotate.service >/dev/null || true
deb-systemd-invoke stop obsapi-delayedjob-queue-quick.service >/dev/null || true
deb-systemd-invoke stop obsapi-delayedjob-queue-releasetracking.service >/dev/null || true
;;
purge|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
......
......@@ -15,6 +15,19 @@ reload_apache()
fi
}
reload_obsapi()
{
systemctl "$1" obsapi-clockwork.service 3>/dev/null || true
systemctl "$1" obsapi-delayedjob-queue-consistency_check.service 3>/dev/null || true
systemctl "$1" obsapi-delayedjob-queue-default.service 3>/dev/null || true
systemctl "$1" obsapi-delayedjob-queue-issuetracking.service 3>/dev/null || true
systemctl "$1" obsapi-delayedjob-queue-mailers.service 3>/dev/null || true
systemctl "$1" obsapi-delayedjob-queue-project_log_rotate.service 3>/dev/null || true
systemctl "$1" obsapi-delayedjob-queue-quick.service 3>/dev/null || true
systemctl "$1" obsapi-delayedjob-queue-releasetracking.service 3>/dev/null || true
echo "obsapi reloaded."
}
case "$1" in
setup)
......@@ -45,19 +58,13 @@ case "$1" in
run_in_api rake assets:precompile RAILS_ENV=production RAILS_GROUPS=assets
run_in_api rake ts:index RAILS_ENV=production || true
# Start up obsapi daemons
if [ -x /usr/sbin/invoke-rc.d ]; then
invoke-rc.d obsapi-clockwork.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-consistency_check.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-default.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-issuetracking.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-mailers.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-project_log_rotate.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-quick.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-releasetracking.service restart 3>/dev/null || true
echo "obsapi restarted."
fi
# Stop delayed jobs and queues that might be running based on the old codebase.
# This is a workaround to migrate from obsapidelayed init script to multiple systemd unit files.
run_in_api script/delayed_job.api.rb stop RAILS_ENV=production || true
run_in_api clockworkd -l -c config/clock.rb stop || true
# Start up obsapi daemons
reload_obsapi start
# Test whether a2enmod is available (and thus also apache2ctl).
if [ -x /usr/sbin/a2enmod ]; then
......@@ -81,18 +88,11 @@ case "$1" in
cd /usr/share/obs/api
RAILS_ENV=production bundle exec rake db:migrate:with_data >> log/db_migrate.log
# Destroy any existent delayed job based on the old codebase
echo 'Delayed::Job.destroy_all' | RAILS_ENV=production bundle exec rails console >> log/destroy_all_jobs.log
# Restart all daemons
if [ -x /usr/sbin/invoke-rc.d ]; then
invoke-rc.d obsapi-clockwork.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-consistency_check.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-default.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-issuetracking.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-mailers.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-project_log_rotate.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-quick.service restart 3>/dev/null || true
invoke-rc.d obsapi-delayedjob-queue-releasetracking.service restart 3>/dev/null || true
echo "obsapi restarted."
fi
reload_obsapi restart
# Restart Apache to really enable the module and load obs.conf
reload_apache restart
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment