diff options
author | Justin Lecher <jlec@gentoo.org> | 2015-08-20 14:22:52 +0200 |
---|---|---|
committer | Justin Lecher <jlec@gentoo.org> | 2015-08-20 14:23:00 +0200 |
commit | 6e8d3a961f248ca9d6fe2e50c4133e48ba5908c6 (patch) | |
tree | bab1f847b5fb73f91b626353bd556b6f88d756c4 /dev-python/celery | |
parent | app-shells/zsh: Set correct subslot dependency for ncurses (diff) | |
download | gentoo-6e8d3a961f248ca9d6fe2e50c4133e48ba5908c6.tar.gz gentoo-6e8d3a961f248ca9d6fe2e50c4133e48ba5908c6.tar.bz2 gentoo-6e8d3a961f248ca9d6fe2e50c4133e48ba5908c6.zip |
dev-python/celery: Fix bracket usage in init script
* use /run instead of /var/run
* Fix dependencies for py3
Package-Manager: portage-2.2.20.1
Signed-off-by: Justin Lecher <jlec@gentoo.org>
Diffstat (limited to 'dev-python/celery')
-rw-r--r-- | dev-python/celery/celery-3.1.18-r1.ebuild | 88 | ||||
-rw-r--r-- | dev-python/celery/files/celery.confd-r2 | 51 | ||||
-rw-r--r-- | dev-python/celery/files/celery.initd-r2 | 206 |
3 files changed, 345 insertions, 0 deletions
diff --git a/dev-python/celery/celery-3.1.18-r1.ebuild b/dev-python/celery/celery-3.1.18-r1.ebuild new file mode 100644 index 000000000000..7d77dd3d56d7 --- /dev/null +++ b/dev-python/celery/celery-3.1.18-r1.ebuild @@ -0,0 +1,88 @@ +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +EAPI=5 + +PYTHON_COMPAT=( python2_7 python3_{3,4} ) + +inherit distutils-r1 bash-completion-r1 + +DESCRIPTION="Open source asynchronous task queue/job queue based on distributed message passing" +HOMEPAGE="http://celeryproject.org/ http://pypi.python.org/pypi/celery" +SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz" + +LICENSE="BSD" +SLOT="0" +KEYWORDS="~amd64 ~x86" +# There are a number of other optional 'extras' which overlap with those of kombu, however +# there has been no apparent expression of interest or demand by users for them. See requires.txt +IUSE="doc examples redis sqs test yaml zeromq" + +RDEPEND=" + <dev-python/kombu-3.1[${PYTHON_USEDEP}] + >=dev-python/kombu-3.0.25[${PYTHON_USEDEP}] + >=dev-python/anyjson-0.3.3[${PYTHON_USEDEP}] + >=dev-python/billiard-3.3.0.20[${PYTHON_USEDEP}] + <dev-python/billiard-3.4[${PYTHON_USEDEP}] + dev-python/pytz[${PYTHON_USEDEP}] + dev-python/greenlet[${PYTHON_USEDEP}] + sqs? ( >=dev-python/boto-2.13.3[${PYTHON_USEDEP}] ) + zeromq? ( >=dev-python/pyzmq-13.1.0[${PYTHON_USEDEP}] ) + yaml? ( >=dev-python/pyyaml-3.10[${PYTHON_USEDEP}] ) +" + +DEPEND=" + dev-python/setuptools[${PYTHON_USEDEP}] + test? ( ${RDEPEND} + dev-python/gevent[$(python_gen_usedep python2_7)] + >=dev-python/mock-1.0.1[${PYTHON_USEDEP}] + dev-python/nose-cover3[${PYTHON_USEDEP}] + >=dev-python/pymongo-2.6.2[${PYTHON_USEDEP}] + dev-python/pyopenssl[${PYTHON_USEDEP}] + >=dev-python/python-dateutil-2.1[${PYTHON_USEDEP}] + dev-python/sqlalchemy[${PYTHON_USEDEP}] + redis? ( + dev-python/redis-py[${PYTHON_USEDEP}] + >=dev-db/redis-2.8.0 + ) + ) + doc? ( + dev-python/docutils[${PYTHON_USEDEP}] + dev-python/sphinx[${PYTHON_USEDEP}] + dev-python/jinja[${PYTHON_USEDEP}] + dev-python/sqlalchemy[${PYTHON_USEDEP}] + )" + +PATCHES=( + "${FILESDIR}"/celery-docs.patch + "${FILESDIR}"/${PN}-3.1.11-test.patch +) + +# testsuite needs it own source +DISTUTILS_IN_SOURCE_BUILD=1 + +python_compile_all() { + if use doc; then + mkdir docs/.build || die + emake -C docs html + fi +} + +python_test() { + nosetests || die "Tests failed with ${EPYTHON}" +} + +python_install_all() { + # Main celeryd init.d and conf.d + newinitd "${FILESDIR}/celery.initd-r2" celery + newconfd "${FILESDIR}/celery.confd-r2" celery + + use examples && local EXAMPLES=( examples/. ) + + use doc && local HTML_DOCS=( docs/.build/html/. ) + + newbashcomp extra/bash-completion/celery.bash ${PN} + + distutils-r1_python_install_all +} diff --git a/dev-python/celery/files/celery.confd-r2 b/dev-python/celery/files/celery.confd-r2 new file mode 100644 index 000000000000..d5ba2f7c9951 --- /dev/null +++ b/dev-python/celery/files/celery.confd-r2 @@ -0,0 +1,51 @@ +# /etc/conf.d/celery + +############################################################################## +# GLOBAL CONFIGURATION + +# User and group +#CELERY_USER="celery" +#CELERY_GROUP="celery" + +# This is generaly a good idea to set the environment correctly +# because a lot of python package try to use HOME on init +#export HOME="/var/lib/myproject" + +# Full path to the python project directory. +#CELERY_PROJDIR="/var/lib/myproject" + +############################################################################## +# CELERYD + +# Start the Celery worker daemon +#CELERYD_ENABLED="yes" + +# celeryd notes +#CELERYD_NODES="celery" + +# celeryd options +# Example: set a 5 minute hard time limit for tasks, disable queue process prefetching and specify an app module from CELERY_PROJDIR +#CELERYD_OPTS="--time-limit=300 -Ofair -A celeryapp" + +# Location and level of the celeryd log file +#CELERYD_LOG_FILE=/var/log/celery/celeryd@%n.log +#CELERYD_LOG_LEVEL="INFO" + +# Location of the celeryd pid file +#CELERYD_PID_FILE=/run/celery/celeryd@%n.pid + +############################################################################## +# CELERYBEAT + +# Start the Celery task scheduler daemon +#CELERYBEAT_ENABLED="yes" + +# celerybeat options +#CELERYBEAT_OPTS="" + +# Location and level of the celerybeat log file +#CELERYBEAT_LOG_FILE=/var/log/celery/celerybeat.log +#CELERYBEAT_LOG_LEVEL="INFO" + +# Location of the celerybeat pid file +#CELERYBEAT_PID_FILE=/run/celery/celerybeat.pid diff --git a/dev-python/celery/files/celery.initd-r2 b/dev-python/celery/files/celery.initd-r2 new file mode 100644 index 000000000000..ec8ffb17e076 --- /dev/null +++ b/dev-python/celery/files/celery.initd-r2 @@ -0,0 +1,206 @@ +#!/sbin/runscript +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the BSD license +# $Id$ + +extra_started_commands="reload" + +depend() { + need net + use rabbitmq redis logger dns +} + +CELERYD_ENABLED=${CELERYD_ENABLED:-"no"} +CELERYD_PID_FILE=${CELERYD_PID_FILE:-"/run/celery/celeryd@%n.pid"} +CELERYD_LOG_FILE=${CELERYD_LOG_FILE:-"/var/log/celery/celeryd@%n.log"} +CELERYD_LOG_LEVEL=${CELERYD_LOG_LEVEL:-"INFO"} +CELERYD_NODES=${CELERYD_NODES:-"celery"} + +CELERYBEAT_ENABLED=${CELERYBEAT_ENABLED:-"no"} +CELERYBEAT_PID_FILE=${CELERYBEAT_PID_FILE:-"/run/celery/celerybeat.pid"} +CELERYBEAT_LOG_FILE=${CELERYBEAT_LOG_FILE:-"/var/log/celery/celerybeat.log"} +CELERYBEAT_LOG_LEVEL=${CELERYBEAT_LOG_LEVEL:-"INFO"} + +export CELERY_LOADER + +CELERYD_MULTI=${CELERYD_MULTI:-"celery multi"} +CELERYCTL=${CELERYCTL:-"celery"} +CELERYBEAT=${CELERYBEAT:-"celery beat"} + +CELERYD_OPTS="${CELERYD_OPTS}" +CELERYBEAT_OPTS="${CELERYBEAT_OPTS} -f ${CELERYBEAT_LOG_FILE} -l ${CELERYBEAT_LOG_LEVEL}" + +create_dirs() { + local logfile="${1}" + local pidfile="${2}" + local logdir=$(dirname ${logfile}) + local piddir=$(dirname ${pidfile}) + + checkpath -d -q -m 0750 -o ${CELERY_USER:-"root"}:${CELERY_GROUP:-"root"} ${logdir} ${piddir} +} + +[ -n "${CELERY_USER}" ] && DAEMON_OPTS="${DAEMON_OPTS} --uid=${CELERY_USER}" +[ -n "${CELERY_GROUP}" ] && DAEMON_OPTS="${DAEMON_OPTS} --gid=${CELERY_GROUP}" + +checkconfig() { + if [ ! -c /dev/null ]; then + eerror "/dev/null is not a character device!" + return 1 + fi + + if [ -z "${CELERY_PROJDIR}" ]; then + eerror "Missing CELERY_PROJDIR variable" + return 1 + fi + + yesno "${CELERYD_ENABLED}" && \ + create_dirs "${CELERYD_LOG_FILE}" "${CELERYD_PID_FILE}" + + yesno "${CELERYBEAT_ENABLED}" && \ + create_dirs "${CELERYBEAT_LOG_FILE}" "${CELERYBEAT_PID_FILE}" + + return 0 +} + +celery_chdir() { + [ -n "${CELERY_PROJDIR}" ] && cd "${CELERY_PROJDIR}" +} + +wait_pid () { + local pidfile=${1} + local timeout=${STOPTIMEOUT:-"10"} + local PID=$(cat "${pidfile}" 2>/dev/null) + + while [ -n "${PID}" ] && [ "${timeout}" -ge 1 ]; do + kill -0 ${PID} 2>/dev/null || break + kill -TERM "${PID}" + timeout=$((${timeout} - 1)) + sleep 0.5 + done + + [ "${timeout}" -lt 1 ] && return 1 + [ -f ${pidfile} ] && rm -f ${pidfile} + return 0 +} + +# celeryd +start_workers() { + yesno "${CELERYD_ENABLED}" || return 0 + + ${CELERYD_MULTI} start ${CELERYD_NODES} ${DAEMON_OPTS} \ + --pidfile="${CELERYD_PID_FILE}" \ + --logfile="${CELERYD_LOG_FILE}" \ + --loglevel="${CELERYD_LOG_LEVEL}" \ + ${CELERYD_OPTS} +} + +stop_workers() { + yesno "${CELERYD_ENABLED}" || return 0 + + local timeout=${STOPTIMEOUT:-"10"} + + ${CELERYD_MULTI} stop ${CELERYD_NODES} --pidfile="${CELERYD_PID_FILE}" || return 1 + + # Wait for each node + for node in ${CELERYD_NODES}; do + local pidfile=${CELERYD_PID_FILE/\%n/${node}} + local PID=$(cat "${pidfile}" 2>/dev/null) + while [ -n "${PID}" ] && [ "${timeout}" -ge 1 ]; do + kill -0 ${PID} 2>/dev/null || break + timeout=$((${timeout} - 1)) + sleep 0.5 + done + done + + [ "${timeout}" -lt 1 ] && return 1 + return 0 +} + +restart_workers() { + yesno "${CELERYD_ENABLED}" || return 0 + + ${CELERYD_MULTI} restart ${CELERYD_NODES} ${DAEMON_OPTS} \ + --pidfile="${CELERYD_PID_FILE}" \ + --logfile="${CELERYD_LOG_FILE}" \ + --loglevel="${CELERYD_LOG_LEVEL}" \ + ${CELERYD_OPTS} +} + +# celerybeat +start_beat() { + yesno "${CELERYBEAT_ENABLED}" || return 0 + + ebegin "Starting celerybeat" + ${CELERYBEAT} ${CELERYBEAT_OPTS} ${DAEMON_OPTS} --detach \ + --pidfile="${CELERYBEAT_PID_FILE}" + eend ${?} +} + + +stop_beat() { + yesno "${CELERYBEAT_ENABLED}" || return 0 + + ebegin "Stopping celerybeat" + if [ -f "${CELERYBEAT_PID_FILE}" ]; then + wait_pid "${CELERYBEAT_PID_FILE}" + else + ewarn "not running" + fi + eend ${?} +} + + +start() { + local cr=0 + + checkconfig || return 1 + + ebegin "Starting ${SVCNAME}" + eindent + + celery_chdir && \ + start_workers && \ + start_beat || cr=1 + + eoutdent + eend ${cr} +} + +stop() { + local cr=0 + + checkconfig || return 1 + + ebegin "Stopping ${SVCNAME}" + eindent + + celery_chdir + stop_workers || cr=1 + stop_beat || cr=1 + + eoutdent + eend ${cr} +} + +reload() { + local cr=0 + + checkconfig || return 1 + + ebegin "Restarting ${SVCNAME}" + eindent + + celery_chdir + restart_workers || cr=1 + stop_beat && start_beat || cr=1 + + eoutdent + eend ${cr} +} + +status() { + checkconfig || return 1 + + celery_chdir && \ + ${CELERYCTL} status +} |