From 04dd14bd0c5d4cb5b4753d67417f549fdac93a8e Mon Sep 17 00:00:00 2001 From: Dmitry Simonenko <pmwkaa@gmail.com> Date: Tue, 15 Nov 2011 13:55:33 +0400 Subject: [PATCH] RPM package build support --- CMakeLists.txt | 1 + cmake/tarantool_cpack.cmake | 15 ++++++- extra/CMakeLists.txt | 7 ++++ extra/tarantool_box | 78 +++++++++++++++++++++++++++++++++++++ extra/tarantool_box.sh | 42 ++++++++++++++++++++ 5 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 extra/CMakeLists.txt create mode 100755 extra/tarantool_box create mode 100755 extra/tarantool_box.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 704c9e39e9..2ccce7846e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -241,6 +241,7 @@ add_subdirectory(mod) add_subdirectory(client) add_subdirectory(test) add_subdirectory(doc EXCLUDE_FROM_ALL) +add_subdirectory(extra) install (FILES README LICENSE doc/box-protocol.txt DESTINATION doc) diff --git a/cmake/tarantool_cpack.cmake b/cmake/tarantool_cpack.cmake index bb4d2e92d7..e20bad6954 100644 --- a/cmake/tarantool_cpack.cmake +++ b/cmake/tarantool_cpack.cmake @@ -1,7 +1,20 @@ # # List generators # -set (CPACK_GENERATOR "TGZ") + +if ("${CPACK_GENERATOR}" STREQUAL "RPM") + set (CPACK_RPM_PACKAGE_REQUIRES "git, gcc44, flex >= 2.5.35, bison, cmake") + set (CPACK_RPM_PACKAGE_NAME "tarantool_box") + set (CPACK_RPM_PACKAGE_SUMMARY "tarantool_box") + set (CPACK_RPM_PACKAGE_VERSION "${TARANTOOL_VERSION}") + set (CPACK_RPM_PACKAGE_RELEASE "8") + set (CPACK_RPM_PACKAGE_LICENSE "BSD") + set (CPACK_RPM_PACKAGE_GROUP "MAIL.RU") + set (CPACK_RPM_PACKAGE_DESCRIPTION "Tarantool in-memory DB storage") +else() + set (CPACK_GENERATOR "TGZ") +endif() + set (CPACK_SOURCE_GENERATOR "TGZ") # # Describe the source distribution diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt new file mode 100644 index 0000000000..5d262449e0 --- /dev/null +++ b/extra/CMakeLists.txt @@ -0,0 +1,7 @@ + +# scripts for RPM package +# +if ("${CPACK_GENERATOR}" STREQUAL "RPM") + install (FILES tarantool_box DESTINATION /etc/init.d) + install (FILES tarantool_box.sh DESTINATION /bin) +endif() diff --git a/extra/tarantool_box b/extra/tarantool_box new file mode 100755 index 0000000000..cbbaf26080 --- /dev/null +++ b/extra/tarantool_box @@ -0,0 +1,78 @@ +#!/bin/bash + +# /etc/rc.d/init.d/tarantool_box +# +# chkconfig: 2345 99 99 +# description: tarantool_box +# processname: tarantool_box + +. /etc/init.d/functions + +RETVAL=0 +INST="$(basename $0)" +export PIDFILE="/var/${INST}/pid" +export WRAP_PIDFILE="/var/${INST}/wrapper.pid" +export OPTIONS="" + +# We must not run immediate! +if [ "${INST}" == "tarantool_box" ] +then + echo_failure + echo + exit +fi + +start() { + echo -n $"Starting ${INST}: " + /usr/local/bin/${INST}.sh ${OPTIONS} >> /var/${INST}/logs/init.log 2>&1 + RETVAL=${?} + if [ ${RETVAL} -eq 0 ] + then + echo_success + else + echo_failure + fi + echo + return ${RETVAL} +} + +stop() { + echo -n $"Stopping $INST: " + if [ -f ${WRAP_PIDFILE} ] + then + kill $(cat ${WRAP_PIDFILE}) >/dev/null 2>&1 + rm -f ${WRAP_PIDFILE} >/dev/null 2>&1 + fi + if [ -f ${PIDFILE} ] + then + kill $(cat ${PIDFILE}) >/dev/null 2>&1 + rm -f ${PIDFILE} >/dev/null 2>&1 + fi + echo_success + echo + return ${RETVAL} +} + +restart(){ + stop + sleep 3 + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + restart + ;; + *) + echo $"Usage: $0 {start|stop}" + RETVAL=1 +esac + +exit ${RETVAL} + diff --git a/extra/tarantool_box.sh b/extra/tarantool_box.sh new file mode 100755 index 0000000000..c1180ed39d --- /dev/null +++ b/extra/tarantool_box.sh @@ -0,0 +1,42 @@ +#!/bin/sh -x + +export PATH=$PATH:/usr/local/bin + +NAME="tarantool_box" +BINARY="/usr/local/bin/${NAME}" +INST=$(basename $0 .sh) +CONF="/usr/local/etc/${INST}.cfg" +LOGDIR="/var/${INST}/logs" +CRONOLOG="/usr/sbin/cronolog" + +exec <&- + +report() +{ + tail -n 500 ${LOGDIR}/tarantool.log | mail -s "${@}" ${MAILTO} +} + +runtarantool() +{ + + ulimit -n 40960 + ${BINARY} ${OPTIONS} --config ${CONF} 2>&1 </dev/null & + wait + RC=${?} + report "${INST} restarted! "`date '+%Y-%m-%d %H:%M:%S'`" exit code $RC" + echo "${INST} restarted! "`date '+%Y-%m-%d %H:%M:%S'`" exit code $RC<br>" >> /var/tmp/error.txt + sleep 2 +} + +{ + ulimit -Hc unlimited + runtarantool + + while true + do + ulimit -Hc 0 + runtarantool + done +} & + +echo $! > ${WRAP_PIDFILE} -- GitLab