Skip to content
Snippets Groups Projects
Commit c5aac099 authored by bigbes's avatar bigbes
Browse files

Remove obsolete file, fix debian rules (bad 'etc' dir)

parent fe625e99
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@ DEB_CMAKE_INSTALL_PREFIX := /usr
DEB_CMAKE_NORMAL_ARGS := -DCMAKE_INSTALL_PREFIX="$(DEB_CMAKE_INSTALL_PREFIX)" \
-DCMAKE_SKIP_RPATH=ON \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_INSTALL_SYSCONFDIR=/etc/tarantool \
-DCMAKE_INSTALL_SYSCONFDIR=/etc \
-DCMAKE_INSTALL_LOCALSTATEDIR=/var \
-DCMAKE_INSTALL_LIBDIR=/usr/lib
# -DCMAKE_C_FLAGS="$(CFLAGS)" \
......
#!/usr/bin/perl
use strict;
use warnings;
my $log = shift or die "usage: $0 some.log\n";
my $reopen;
$SIG{HUP} = sub { $reopen = 1 };
my $fh;
while (<STDIN>) {
if ($reopen or not $fh) {
undef $fh;
undef $reopen;
if (open $fh, ">>", $log) {
select $fh;
$| = 1;
}
}
print;
}
#!/bin/bash
# /etc/rc.d/init.d/tarantool
#
# chkconfig: 2345 99 99
# description: tarantool
# processname: tarantool
. /etc/init.d/functions
RETVAL=0
# If we're running from sysinit, the basename is
# prefixed with a prefix like:
# /etc/rc3.d/S99tarantool1.1 -> ../init.d/tarantool1.1
# Filter S99 out.
INST=$(basename $0 | sed 's/^[SK][0-9]\{2\}//g')
export PIDFILE="/var/${INST}/box.pid"
export WRAP_PIDFILE="/var/${INST}/wrapper.pid"
export OPTIONS=""
# This script is normally invoked via a symlink.
# An own symlink is created for each instance.
# E.g., in case of 4 instances, there are symlinks
# tarantool0, tarantool1, tarantool2, tarantool3.
# If, for some reason, this script is invoked not via
# a symlink, do nothing.
#
if [ "${INST}" == "tarantool" ]
then
echo_failure
echo
exit
fi
checkactive() {
if [ -f ${WRAP_PIDFILE} ]
then
ps -p $(cat ${WRAP_PIDFILE}) >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo -n "(instance is active)"
echo_failure
exit 1
fi
fi
if [ -f ${PIDFILE} ]
then
ps -p $(cat ${PIDFILE}) >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo -n "(instance is active)"
echo_failure
exit 1
fi
fi
}
start() {
echo -n $"Starting ${INST}: "
checkactive
/usr/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}
}
terminate() {
timeout=${1}
pid=${2}
kill ${pid} >/dev/null 2>&1
sleep ${timeout}
ps -p ${pid} >/dev/null 2>&1
if [ $? -eq 0 ]; then
sleep 10;
ps -p ${pid} >/dev/null 2>&1
if [ $? -eq 0 ]; then
kill -9 ${pid}
sleep 3
ps -p 0 ${pid} >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo_failure
exit 1
fi
fi
fi
}
stop() {
echo -n $"Stopping $INST: "
if [ -f ${WRAP_PIDFILE} ]
then
terminate 1 $(cat ${WRAP_PIDFILE})
rm -f ${WRAP_PIDFILE} >/dev/null 2>&1
fi
if [ -f ${PIDFILE} ]
then
terminate 3 $(cat ${PIDFILE})
rm -f ${PIDFILE} >/dev/null 2>&1
fi
echo_success
echo
return ${RETVAL}
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
RETVAL=1
esac
exit ${RETVAL}
#!/bin/sh
#
# Copyright (C) 2012 Mail.RU
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# Tarantool instance deployment script
#
prompt_name=`basename $0`
act_prompt=1
act_status=0
act_debug=0
act_dry=0
act_quiet=0
error() {
echo "$prompt_name error: $*" 1>&2
exit 1
}
log() {
echo "$prompt_name: $*"
}
usage() {
echo "Tarantool deployment script: add more Tarantool instances."
echo "usage: tarantool_deploy.sh [options] <instance>"
echo
echo " --prefix <path> installation path (/usr)"
echo " --prefix_etc <path> installation etc path (/etc)"
echo " --prefix_var <path> installation var path (/var)"
echo
echo " --status display deployment status"
echo " --dry don't create anything, show commands"
echo
echo " --debug show commands"
echo " --yes don't prompt"
echo " --help display this usage"
echo
exit $1
}
rollback_instance() {
id=$1
workdir="${prefix_var}/tarantool$id"
config="${prefix_etc}/tarantool/tarantool$id.cfg"
rm -rf $workdir
rm -f $config
rm -f "${prefix}/bin/tarantool$id.sh"
rm -f "${prefix_etc}/init.d/tarantool$id"
}
rollback() {
log ">>> rollback changes"
rollback_instance $deploy_name
exit 1
}
try() {
cmd="$*"
[ $act_debug -gt 0 ] && log "$cmd"
if [ $act_dry -eq 0 ]; then
eval "$cmd"
if [ $? -gt 0 ]; then
rollback
fi
fi
}
deploy() {
id=$1
workdir="${prefix_var}/tarantool$id"
config="${prefix_etc}/tarantool/tarantool$id.cfg"
log ">>> deploy instance $id"
# setup work environment
try "mkdir -p $workdir/logs"
# setup startup snapshot
try "cp \"${prefix}/share/tarantool/00000000000000000001.snap\" $workdir"
try "chown tarantool:tarantool -R $workdir"
# setup configuration file
try "cp \"${prefix_etc}/tarantool/tarantool.cfg\" $config"
try 'echo work_dir = \"$workdir\" >> $config'
try 'echo username = \"tarantool\" >> $config'
try 'echo logger = \"cat - \>\> logs/tarantool.log\" >> $config'
# setup wrapper
try "ln -s \"${prefix}/bin/tarantool_multi.sh\" \"${prefix}/bin/tarantool$id.sh\""
# setup startup script
try "ln -s \"${prefix_etc}/init.d/tarantool\" \"${prefix_etc}/init.d/tarantool$id\""
# register service
[ -x /sbin/chkconfig ] && try "/sbin/chkconfig --add tarantool$id"
}
deploy_check() {
id=$1
# check, if instance is already exist (configuration file, consistent way)
if [ $deploy_exists -eq 1 ]; then
grep "^\(${id}\)$" $deploy_cfg > /dev/null
if [ $? -eq 0 ]; then
[ $act_quiet -eq 0 ] && log "Instance '${id}' is already deployed."
exit 0
fi
fi
# check, if there are any instance-related files exists that could be
# accidently removed or overwritten by setup.
instance_workdir="${prefix_var}/tarantool$id"
instance_config="${prefix_etc}/tarantool/tarantool$id.cfg"
instance_wrapper="${prefix}/bin/tarantool$id.sh"
instance_startup="${prefix_etc}/init.d/tarantool$id"
[ -d $instance_workdir ] && error "Instance workdir exists: '$instance_workdir'"
[ -f $instance_config ] && error "Instance configuration file exists: $instance_config"
[ -f $instance_wrapper ] && error "Instance wrapper file exists: $instance_wrapper"
[ -f $instance_startup ] && error "Instance startup file exists: $instance_startup"
}
commit() {
log ">>> updating deployment config"
try "echo $1 >> $deploy_cfg"
}
# process command line arguments
[ $# -eq 0 ] && usage 1
deploy_name_set=0
deploy_name=""
while [ $# -ge 1 ]; do
case $1 in
--yes) act_prompt=0; shift 1 ;;
--quiet) act_quiet=1; shift 1 ;;
--prefix) prefix=$2; shift 2 ;;
--prefix_var) prefix_var=$2; shift 2 ;;
--prefix_etc) prefix_etc=$2; shift 2 ;;
--dry) act_dry=1 ; act_debug=1 ; shift 1 ;;
--debug) act_debug=1; shift 1 ;;
--status) act_status=1; shift 1 ;;
--help) usage 0; shift 1 ;;
*) deploy_name=$1; deploy_name_set=1; break ;;
esac
done
set ${prefix:="/usr"}
set ${prefix_var:="/var"}
set ${prefix_etc:="/etc"}
deploy_cfg="${prefix_etc}/tarantool/tarantool_deploy.cfg"
deploy_exists=0
# check deployment configuration file
[ -f $deploy_cfg ] && deploy_exists=1
# do migration from old deployment (if necessary)
if [ $deploy_exists -eq 0 ]; then
deploy_cfg_old="/usr/local/etc/tarantool_deploy.cfg"
mkdir -p /etc/tarantool
if [ -f $deploy_cfg_old ]; then
cp /usr/local/etc/tarantool* "${prefix_etc}/tarantool/"
deploy_exists=1
fi
fi
# display status
if [ $act_status -ne 0 ]; then
if [ $deploy_exists -eq 0 ]; then
log "No tarantool instances found."
else
log "Current instances:\n`cat $deploy_cfg`"
fi
exit 0
fi
# check that instance name was specified
[ $deploy_name_set -eq 0 ] && usage 1
# validate instance name
echo $deploy_name | grep '^[[:digit:]]\+.\(1\|2\)' > /dev/null
if [ $? -eq 1 ]; then
error "Bad instance name format, should be e.g: 1.1, 1.2, etc."
fi
# check if it consistent to deploy new instance
deploy_check $deploy_name
# ask permission to continue
if [ $act_prompt -eq 1 ]; then
[ $act_dry -ne 0 ] && log "(dry mode)"
log "About to deploy Tarantool instance $deploy_name."
log "Continue? [n/y]"
read answer
case "$answer" in
[Yy]) ;;
*)
log "Abort"
exit 0
;;
esac
fi
deploy $deploy_name
commit $deploy_name
log "done"
# __EOF__
#!/bin/sh -x
# A wrapper script to run a single tarantool instance
# and restart it when it crashes
export PATH=$PATH:/usr/bin
NAME="tarantool"
BINARY="/usr/bin/${NAME}"
INST=$(basename $0 .sh)
CONF="/etc/tarantool/${INST}.cfg"
LOGDIR="/var/${INST}/logs"
WRAP_PIDFILE="/var/${INST}/wrapper.pid"
# set to get restart emails
#MAILTO=""
exec <&-
report()
{
if [ "${MAILTO}" ]; then
tail -n 500 ${LOGDIR}/tarantool.log | mail ${MAILTO} -s "\"${INST} is restarted\""
fi
echo \""${@}"\" >> ${LOGDIR}/wrapper.log
}
runtarantool()
{
ulimit -n 40960
${BINARY} ${OPTIONS} --config ${CONF} 2>&1 </dev/null &
wait
RC=${?}
report "${INST}: ${BINARY} ${OPTIONS} --config ${CONF} died prematurely "`date '+%Y-%m-%d %H:%M:%S'`" exit code $RC"
sleep 2
}
{
ulimit -c unlimited
runtarantool
while true
do
ulimit -c 0
runtarantool
done
} &
echo $! > ${WRAP_PIDFILE}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment