Skip to content

Commit

Permalink
add rpm spec file, new sysv init script
Browse files Browse the repository at this point in the history
git-svn-id: http://code.sixapart.com/svn/memcached/trunk/server@543 b0b603af-a30f-0410-a34e-baf09ae79d0b
  • Loading branch information
lindner committed May 4, 2007
1 parent 24d9040 commit 275f8c4
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2007-05-04 Paul Lindner <[email protected]>

* Add fedora/redhat style init script and RPM spec file

2007-05-12 [Version 1.2.2 released]

2007-04-16 Steven Grimm <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ memcached_debug_LDADD = $(memcached_LDADD)

SUBDIRS = doc
DIST_DIRS = scripts
EXTRA_DIST = doc scripts TODO t
EXTRA_DIST = doc scripts TODO t memcached.spec

test: memcached-debug
prove t
Expand Down
99 changes: 99 additions & 0 deletions memcached.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
Name: memcached
Version: 1.2.2
Release: 1%{?dist}
Summary: High Performance, Distributed Memory Object Cache

Group: System Environment/Daemons
License: BSD
URL: http://www.danga.com/memcached/
Source0: http://www.danga.com/memcached/dist/%{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires: libevent-devel

Requires: libevent
Requires: perl
Requires(post): /sbin/chkconfig
Requires(preun): /sbin/chkconfig, /sbin/service
Requires(postun): /sbin/service


%description

memcached is a high-performance, distributed memory object caching
system, generic in nature, but intended for use in speeding up dynamic
web applications by alleviating database load.

Available rpmbuild rebuild options :
--with=threads - build a multiprocessor optimized memcached server

%prep
%setup -q


%build
%configure \
%{?_with_threads:--enable-threads}

make %{?_smp_mflags}

%check
# skip this for now, this requires perl and a bunch of other stuff
# and may not work from within rpmbuild
#make test

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT

# Perl script monitoring memcached
install -Dp -m0755 $RPM_BUILD_DIR/%{name}-%{version}/scripts/memcached-tool %{buildroot}%{_bindir}/memcached-tool

# Init script
install -Dp -m0755 $RPM_BUILD_DIR/%{name}-%{version}/scripts/memcached.sysv %{buildroot}%{_sysconfdir}/rc.d/init.d/memcached

# Default configs
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig
cat <<EOF >$RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/%{name}
PORT="11211"
USER="nobody"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""
EOF

%clean
rm -rf $RPM_BUILD_ROOT


%post
/sbin/chkconfig --add %{name}

%preun
if [ "$1" = 0 ] ; then
/sbin/service %{name} stop > /dev/null 2>&1
/sbin/chkconfig --del %{name}
fi
exit 0

%postun
if [ "$1" -ge 1 ]; then
/sbin/service %{name} condrestart > /dev/null 2>&1
fi
exit 0


%files
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README TODO doc/CONTRIBUTORS doc/*.txt
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%{_bindir}/memcached-tool
%{_bindir}/memcached
%{_bindir}/memcached-debug
%{_mandir}/man1/memcached.1*
%{_sysconfdir}/rc.d/init.d/memcached


%changelog
* Fri May 4 2007 Paul Lindner <[email protected]> - 1.2.2-1
- Initial spec file created via rpmdev-newspec
76 changes: 76 additions & 0 deletions scripts/memcached.sysv
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#! /bin/sh
#
# chkconfig: - 55 45
# description: The memcached daemon is a network memory cache service.
# processname: memcached
# config: /etc/sysconfig/memcached

# Source function library.
. /etc/rc.d/init.d/functions

PORT=11211
USER=nobody
MAXCONN=1024
CACHESIZE=64
OPTIONS=""

if [ -f /etc/sysconfig/memcached ];then
. /etc/sysconfig/memcached
fi

# Check that networking is up.
if [ "$NETWORKING" = "no" ]
then
exit 0
fi

RETVAL=0
prog="memcached"

start () {
echo -n $"Starting $prog: "
daemon memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P /var/run/memcached.pid $OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached
}
stop () {
echo -n $"Stopping $prog: "
killproc memcached
RETVAL=$?
echo
if [ $RETVAL -eq 0 ] ; then
rm -f /var/lock/subsys/memcached
rm -f /var/run/memcached.pid
fi
}

restart () {
stop
start
}


# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status memcached
;;
restart|reload)
restart
;;
condrestart)
[ -f /var/lock/subsys/memcached ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
exit 1
esac

exit $?

0 comments on commit 275f8c4

Please sign in to comment.