public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-x86 commit in dev-python/celery/files: celery.initd celery.confd
@ 2012-05-30  6:45 Corentin Chary (iksaif)
  0 siblings, 0 replies; 2+ messages in thread
From: Corentin Chary (iksaif) @ 2012-05-30  6:45 UTC (permalink / raw
  To: gentoo-commits

iksaif      12/05/30 06:45:54

  Added:                celery.initd celery.confd
  Log:
  New ebuild for celery. Closes bug #342041.
  
  (Portage version: 2.1.10.63/cvs/Linux x86_64)

Revision  Changes    Path
1.1                  dev-python/celery/files/celery.initd

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/celery/files/celery.initd?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/celery/files/celery.initd?rev=1.1&content-type=text/plain

Index: celery.initd
===================================================================
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-python/celery/files/celery.initd,v 1.1 2012/05/30 06:45:54 iksaif Exp $

extra_started_commands="reload"

depend() {
        need net
	use rabbitmq logger dns
}

CELERYD_ENABLED=${CELERYD_ENABLED:-"no"}
CELERYD_PID_FILE=${CELERYD_PID_FILE:-"/var/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:-"/var/run/celery/celerybeat.pid"}
CELERYBEAT_LOG_FILE=${CELERYBEAT_LOG_FILE:-"/var/log/celery/celerybeat.log"}
CELERYBEAT_LOG_LEVEL=${CELERYBEAT_LOG_LEVEL:-"INFO"}

CELERYEV_ENABLED=${CELERYEV_ENABLED:-"no"}
CELERYEV_PID_FILE=${CELERYEV_PID_FILE:-"/var/run/celery/celeryev.pid"}
CELERYEV_LOG_FILE=${CELERYEV_LOG_FILE:-"/var/log/celery/celeryev.log"}
CELERYEV_LOG_LEVEL=${CELERYEV_LOG_LEVEL:-"INFO"}

export CELERY_LOADER

if yesno "$CELERY_DJANGO"; then
	CELERYD=${CELERYD:-"celeryd_detach"}
	CELERYCTL=${CELERYCTL:-"python manage.py celeryd"}
	CELERYD_MULTI=${CELERYD_MULTI:-"python manage.py celeryd_multi"}
	CELERYBEAT=${CELERYBEAT:-"python manage.py celerybeat"}
	CELERYEV=${CELERYEV:-"python manage.py celeryev"}
	CELERYEV_CAM=${CELERYEV_CAM:-"djcelery.snapshot.Camera"}
else
	CELERYD=${CELERYD:-"-m celery.bin.celeryd_detach"}
	CELERYD_MULTI=${CELERYD_MULTI:-"celeryd-multi"}
	CELERYCTL=${CELERYCTL:-"celeryctl"}
	CELERYBEAT=${CELERYBEAT:-"celerybeat"}
	CELERYEV=${CELERYEV:-"celeryev"}
fi

CELERYD_OPTS="$CELERYD_OPTS -f $CELERYD_LOG_FILE -l $CELERYD_LOG_LEVEL"
CELERYBEAT_OPTS="$CELERYBEAT_OPTS -f $CELERYBEAT_LOG_FILE -l $CELERYBEAT_LOG_LEVEL"
CELERYEV_OPTS="$CELERYEV_OPTS -f $CELERYEV_LOG_FILE -l $CELERYEV_LOG_LEVEL -c $CELERYEV_CAM"

create_dirs() {
	local logfile="$1"
	local pidfile="$2"
	local logdir=`dirname $logfile`
	local piddir=`dirname $pidfile`

	if [ ! -d "$logdir" ]; then
		mkdir -p $logdir
	fi
	if [ ! -d "$piddir" ]; then
		mkdir -p $piddir
	fi

	if [ -n "$CELERY_USER" ]; then
		chown "$CELERY_USER" $logdir $piddir
	fi
	if [ -n "$CELERY_GROUP" ]; then
		chown ":$CELERY_GROUP" $logdir $piddir
	fi
}

if [ -n "$CELERY_USER" ]; then
	DAEMON_OPTS="$DAEMON_OPTS --uid=$CELERY_USER"
fi
if [ -n "$CELERY_GROUP" ]; then
	DAEMON_OPTS="$DAEMON_OPTS --gid=$CELERY_GROUP"
fi

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

	if yesno "$CELERYD_ENABLED"; then
		create_dirs "$CELERYD_LOG_FILE" "$CELERYD_PID_FILE"
	fi

	if yesno "$CELERYBEAT_ENABLED"; then
		create_dirs "$CELERYBEAT_LOG_FILE" "$CELERYBEAT_PID_FILE"
	fi

	if yesno "$CELERYEV_ENABLED"; then
		create_dirs "$CELERYEV_LOG_FILE" "$CELERYEV_PID_FILE"

		if [ -z "$CELERYEV_CAM" ]; then
			eerror "Missing CELERYEV_CAM variable"
			return 1
		fi
	fi

	return 0
}

celery_chdir() {
	if [ -n "$CELERY_PROJDIR" ]; then
		cd "$CELERY_PROJDIR"
	fi
}

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"    \
                --cmd="$CELERYD"                   \
                $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"  \
                --cmd="$CELERYD"                 \
                $CELERYD_OPTS
}

# celeryev
start_ev() {
	yesno "${CELERYEV_ENABLED}" || return 0

	ebegin "Starting celeryev"
	$CELERYEV $CELERYEV_OPTS $DAEMON_OPTS --detach \
		--pidfile="$CELERYEV_PID_FILE"
	eend $?
}


stop_ev() {
	yesno "${CELERYEV_ENABLED}" || return 0

	ebegin "Stopping celeryev"
	if [ -f "$CELERYEV_PID_FILE" ]; then
		wait_pid "$CELERYEV_PID_FILE"
	else
		eerror "not running"
	fi
	eend $?
}

# 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
		eerror "not running"
	fi
	eend $?
}


start() {
	local cr=0

	checkconfig || return 1

	ebegin "Starting ${SVCNAME}"
	eindent

	celery_chdir && \
		start_workers && \
		start_beat && \
		start_ev || 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
	stop_ev || 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
	stop_ev && start_ev || cr=1

	eoutdent
	eend $cr
}

status() {
	checkconfig || return 1

	${CELERYCTL} status
}



1.1                  dev-python/celery/files/celery.confd

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/celery/files/celery.confd?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/celery/files/celery.confd?rev=1.1&content-type=text/plain

Index: celery.confd
===================================================================
# /etc/conf.d/celery

##############################################################################
# GLOBAL CONFIGURATION

# User and group
#CELERY_USER="celery"
#CELERY_GROUP="celery"

# Is this for a django project ?
# If 'yes' it will automatically setup CELERYD, CELERYCTL
# CELERYD_MULTI, CELERYBEAT, CELERYEV and CELERYEV_CAM for a
# django project, but you can still override them here.
#CELERY_DJANGO="yes"

# Full path to the python project directory.
#CELERY_PROJDIR="/var/lib/myproject"

##############################################################################
# CELERYD

#CELERYD_ENABLED="yes"

# celeryd notes
#CELERYD_NODES="celery"

# celeryd options
# Example: 5 minute hard time limit for tasks
#CELERYD_OPTS="--time-limit=300"

# 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=/var/run/celery/celeryd@%n.pid

##############################################################################
# CELERYBEAT

#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=/var/run/celery/celerybeat.pid

##############################################################################
# CELERYEV

#CELERYEV_ENABLED="yes"

# celeryev options
#CELERYEV_OPTS=""

# Location and level of the celeryev log file
#CELERYEV_LOG_FILE=/var/log/celery/celeryev.log
#CELERYEV_LOG_LEVEL="INFO"

# Location of the celeryev pid file
#CELERYEV_PID_FILE=/var/run/celery/celeryev.pid






^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gentoo-commits] gentoo-x86 commit in dev-python/celery/files: celery.initd celery.confd
@ 2012-08-15  8:25 Corentin Chary (iksaif)
  0 siblings, 0 replies; 2+ messages in thread
From: Corentin Chary (iksaif) @ 2012-08-15  8:25 UTC (permalink / raw
  To: gentoo-commits

iksaif      12/08/15 08:25:23

  Modified:             celery.initd celery.confd
  Log:
  Enhance init script.
  
  (Portage version: 2.1.11.10/cvs/Linux x86_64)

Revision  Changes    Path
1.3                  dev-python/celery/files/celery.initd

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/celery/files/celery.initd?rev=1.3&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/celery/files/celery.initd?rev=1.3&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/celery/files/celery.initd?r1=1.2&r2=1.3

Index: celery.initd
===================================================================
RCS file: /var/cvsroot/gentoo-x86/dev-python/celery/files/celery.initd,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- celery.initd	16 Jul 2012 08:33:58 -0000	1.2
+++ celery.initd	15 Aug 2012 08:25:23 -0000	1.3
@@ -1,7 +1,7 @@
 #!/sbin/runscript
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the BSD license
-# $Header: /var/cvsroot/gentoo-x86/dev-python/celery/files/celery.initd,v 1.2 2012/07/16 08:33:58 iksaif Exp $
+# $Header: /var/cvsroot/gentoo-x86/dev-python/celery/files/celery.initd,v 1.3 2012/08/15 08:25:23 iksaif Exp $
 
 extra_started_commands="reload"
 
@@ -43,29 +43,17 @@
 	CELERYEV=${CELERYEV:-"celeryev"}
 fi
 
-CELERYD_OPTS="$CELERYD_OPTS -f $CELERYD_LOG_FILE -l $CELERYD_LOG_LEVEL"
+CELERYD_OPTS="$CELERYD_OPTS"
 CELERYBEAT_OPTS="$CELERYBEAT_OPTS -f $CELERYBEAT_LOG_FILE -l $CELERYBEAT_LOG_LEVEL"
 CELERYEV_OPTS="$CELERYEV_OPTS -f $CELERYEV_LOG_FILE -l $CELERYEV_LOG_LEVEL -c $CELERYEV_CAM"
 
 create_dirs() {
 	local logfile="$1"
 	local pidfile="$2"
-	local logdir=`dirname $logfile`
-	local piddir=`dirname $pidfile`
+	local logdir=$(dirname $logfile)
+	local piddir=$(dirname $pidfile)
 
-	if [ ! -d "$logdir" ]; then
-		mkdir -p $logdir
-	fi
-	if [ ! -d "$piddir" ]; then
-		mkdir -p $piddir
-	fi
-
-	if [ -n "$CELERY_USER" ]; then
-		chown "$CELERY_USER" $logdir $piddir
-	fi
-	if [ -n "$CELERY_GROUP" ]; then
-		chown ":$CELERY_GROUP" $logdir $piddir
-	fi
+	checkpath -d -q -m 0750 -o ${CELERY_USER:-"root"}:${CELERY_GROUP:-"root"} $logdir $piddir
 }
 
 if [ -n "$CELERY_USER" ]; then



1.2                  dev-python/celery/files/celery.confd

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/celery/files/celery.confd?rev=1.2&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/celery/files/celery.confd?rev=1.2&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/celery/files/celery.confd?r1=1.1&r2=1.2

Index: celery.confd
===================================================================
RCS file: /var/cvsroot/gentoo-x86/dev-python/celery/files/celery.confd,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- celery.confd	30 May 2012 06:45:54 -0000	1.1
+++ celery.confd	15 Aug 2012 08:25:23 -0000	1.2
@@ -13,6 +13,10 @@
 # django project, but you can still override them here.
 #CELERY_DJANGO="yes"
 
+# 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"
 





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-08-15  8:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-30  6:45 [gentoo-commits] gentoo-x86 commit in dev-python/celery/files: celery.initd celery.confd Corentin Chary (iksaif)
  -- strict thread matches above, loose matches on Subject: below --
2012-08-15  8:25 Corentin Chary (iksaif)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox