diff options
author | rodent <rodent@pkgsrc.org> | 2014-04-30 05:39:19 +0000 |
---|---|---|
committer | rodent <rodent@pkgsrc.org> | 2014-04-30 05:39:19 +0000 |
commit | efffc22056bce9a346cc1a2b7bea6fc5f1334997 (patch) | |
tree | 92c53d50b6568e64381877fd84e73639fda62c4e /devel/memcached | |
parent | 8318cc728c039680c0598b95bf93322e586cc59c (diff) | |
download | pkgsrc-efffc22056bce9a346cc1a2b7bea6fc5f1334997.tar.gz |
Make rc.d init script work more like www/spawn-fcgi to facilitate the
execution of multiple memcached instances. Create home directory in
VARBASE/chroot/memcached for these PID files. Add MESSAGE to explain usage
to user. Usage is simple - set the following in rc.conf:
memcached=YES
memcached_jobs="job0 ... jobN"
memcached_job0_args="-p 11211 -m 64 -c 1024"
...
memcached_jobN_args="-p 1121N -m 64 -c 1024"
Bump PKGREVISION.
Diffstat (limited to 'devel/memcached')
-rw-r--r-- | devel/memcached/MESSAGE | 19 | ||||
-rw-r--r-- | devel/memcached/Makefile | 11 | ||||
-rw-r--r-- | devel/memcached/files/memcached.sh | 71 |
3 files changed, 96 insertions, 5 deletions
diff --git a/devel/memcached/MESSAGE b/devel/memcached/MESSAGE new file mode 100644 index 00000000000..7d36b60db38 --- /dev/null +++ b/devel/memcached/MESSAGE @@ -0,0 +1,19 @@ +=========================================================================== +$NetBSD: MESSAGE,v 1.1 2014/04/30 05:39:19 rodent Exp $ + +If using the rc.d init system, set the following variables in rc.conf: + +memcached=YES +memcached_jobs="job0 ... jobN" +memcached_job0_args="-p 11211 -m 64 -c 1024" +... +memcached_jobN_args="-p 1121N -m 64 -c 1024" + +to start as many memcached instances as desired with the required options. +PID files for each instance will be created in: + +${PKG_HOME} named as: + +${PKGBASE}-job0.pid ... ${PKGBASE}-jobN.pid. + +=========================================================================== diff --git a/devel/memcached/Makefile b/devel/memcached/Makefile index 36b8fd3e686..3462c26d7e5 100644 --- a/devel/memcached/Makefile +++ b/devel/memcached/Makefile @@ -1,6 +1,7 @@ -# $NetBSD: Makefile,v 1.38 2014/04/25 09:27:37 wiz Exp $ +# $NetBSD: Makefile,v 1.39 2014/04/30 05:39:19 rodent Exp $ DISTNAME= memcached-1.4.18 +PKGREVISION= 1 CATEGORIES= devel MASTER_SITES= http://www.memcached.org/files/ @@ -21,14 +22,18 @@ INSTALLATION_DIRS= share/doc/${PKGBASE} share/examples/rc.d .include "options.mk" +BUILD_DEFS+= VARBASE MEMCACHED_USER?= memcached MEMCACHED_GROUP?= memcached +PKG_HOME?= ${VARBASE}/chroot/${PKGBASE} PKG_GROUPS= ${MEMCACHED_GROUP} -PKG_USERS= ${MEMCACHED_USER}:${MEMCACHED_GROUP} +PKG_USERS= ${MEMCACHED_USER}:${MEMCACHED_GROUP}::Memcached:${PKG_HOME} PKG_GROUPS_VARS+= MEMCACHED_GROUP PKG_USERS_VARS+= MEMCACHED_USER +OWN_DIRS_PERMS+= ${PKG_HOME} ${MEMCACHED_USER} ${MEMCACHED_GROUP} 0700 FILES_SUBST+= MEMCACHED_USER=${MEMCACHED_USER} -FILES_SUBST+= MEMCACHED_GROUP=${MEMCACHED_GROUP} +FILES_SUBST+= MEMCACHED_GROUP=${MEMCACHED_GROUP} PKG_HOME=${PKG_HOME} +MESSAGE_SUBST+= PKG_HOME=${PKG_HOME} TEST_TARGET= test diff --git a/devel/memcached/files/memcached.sh b/devel/memcached/files/memcached.sh index de0cf163ea8..35811931a6c 100644 --- a/devel/memcached/files/memcached.sh +++ b/devel/memcached/files/memcached.sh @@ -1,6 +1,6 @@ #!@RCD_SCRIPTS_SHELL@ # -# $NetBSD: memcached.sh,v 1.1 2010/02/27 20:40:52 morr Exp $ +# $NetBSD: memcached.sh,v 1.2 2014/04/30 05:39:19 rodent Exp $ # # PROVIDE: memcached @@ -11,7 +11,74 @@ $_rc_subr_loaded . /etc/rc.subr name="memcached" rcvar=$name command="@PREFIX@/bin/${name}" -command_args="-d -u @MEMCACHED_USER@" +command_args="-d" +start_cmd="memcached_start" +stop_cmd="memcached_stop" +status_cmd="memcached_status" +pidfile_base="@PKG_HOME@/memcached-" + +memcached_pid() +{ + pidfile="${pidfile_base}$1.pid" + rc_pid=`check_pidfile "$pidfile" $command` +} + +memcached_start() +{ + rv=0 + for job in "" $memcached_jobs; do + [ -z $job ] && continue + memcached_pid $job + if [ -n "${rc_pid}" ]; then + echo "${name}/$job already running (pid=${rc_pid})." + rv=1 + continue + fi + job_args=$(eval echo \$${name}_${job}_args) + + echo "Starting ${name}/$job." + $command \ + -u @MEMCACHED_USER@ \ + $command_args \ + ${job_args} \ + -P "${pidfile_base}${job}.pid" + done + return $rv +} + +memcached_stop() +{ + rv=0 + for job in "" $memcached_jobs; do + [ -z $job ] && continue + memcached_pid $job + if [ -n "${rc_pid}" ]; then + echo "Stopping ${name}/$job." + kill -TERM ${rc_pid} + wait_for_pids ${rc_pid} + else + echo "${name}/$job is not running." + rv=1 + fi + done + return $rv +} + +memcached_status() +{ + rv=0 + for job in "" $memcached_jobs; do + [ -z $job ] && continue + memcached_pid $job + if [ -n "${rc_pid}" ]; then + echo "${name}/${job} is running as pid ${rc_pid}." + else + echo "${name}/${job} is not running." + rv=1 + fi + done + return $rv +} load_rc_config $name run_rc_command "$1" |