From 4e2a1c3e52183445a9d927b8d52bb2eb21b532ee Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Mon, 28 Jun 2021 12:18:48 -0400 Subject: [PATCH] Add worker wrapper to fix Deb incompatibility Celery 5.x introduced a new worker argument format that is not backwards-compatible with the older Celery 4.x format. This created a conundrum since we use one service unit for both Debian 10 (4.x) and Debian 11 (5.x). Instead of worse hacks, create a wrapper script to start the worker with the correct arguments instead. --- api-daemon/pvcapid-worker.service | 2 +- api-daemon/pvcapid-worker.sh | 40 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100755 api-daemon/pvcapid-worker.sh diff --git a/api-daemon/pvcapid-worker.service b/api-daemon/pvcapid-worker.service index 58adcf43..f79f58f5 100644 --- a/api-daemon/pvcapid-worker.service +++ b/api-daemon/pvcapid-worker.service @@ -9,7 +9,7 @@ Type = simple WorkingDirectory = /usr/share/pvc Environment = PYTHONUNBUFFERED=true Environment = PVC_CONFIG_FILE=/etc/pvc/pvcapid.yaml -ExecStart = /usr/bin/celery --app pvcapid.flaskapi.celery worker --concurrency 1 --loglevel INFO +ExecStart = /usr/share/pvc/pvcapid-worker.sh Restart = on-failure [Install] diff --git a/api-daemon/pvcapid-worker.sh b/api-daemon/pvcapid-worker.sh new file mode 100755 index 00000000..9ff5505e --- /dev/null +++ b/api-daemon/pvcapid-worker.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# pvcapid-worker.py - API Celery worker daemon startup stub +# Part of the Parallel Virtual Cluster (PVC) system +# +# Copyright (C) 2018-2021 Joshua M. Boniface +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################### + +CELERY_BIN="$( which celery )" + +# This absolute hackery is needed because Celery got the bright idea to change how their +# app arguments work in a non-backwards-compatible way with Celery 5. +case "$( cat /etc/debian_version )" in + 10.*) + CELERY_ARGS="worker --app pvcapid.flaskapi.celery --concurrency 1 --loglevel INFO" + ;; + 11.*) + CELERY_ARGS="--app pvcapid.flaskapi.celery worker --concurrency 1 --loglevel INFO" + ;; + *) + echo "Invalid Debian version found!" + exit 1 + ;; +esac + +${CELERY_BIN} ${CELERY_ARGS} +exit $?