/usr/sbin/tarantool_instance is in tarantool-common 1.5.1.218.g1a69fd6-1ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | #!/bin/sh
set -e
CFG=$1
ACTION=$2
CONFIG_DIR=/var/lib/tarantool/started
SNAPSHOT_DIR=/var/lib/tarantool/snapshot
PID_DIR=/var/run/tarantool
LOG_DIR=/var/log/tarantool
BOX=/usr/bin/tarantool_box
SSD=start-stop-daemon
CFG_DIR=/etc/tarantool/instances.enabled
cd $CFG_DIR
usage="Usage: sh $0 /path/to/config.file start|stop"
if ! test -x $BOX; then
exit 0
fi
if test -z "$CFG"; then
echo $usage
exit 5
fi
if ! echo $ACTION|grep -q '^\(start\|stop\)$'; then
echo $usage
exit 5
fi
if ! test -r "$CFG"; then
if echo $CFG|grep -q '\.cfg$'; then
echo File $CFG not found
exit 10
else
if ! test -r "$CFG.cfg"; then
echo "Instance config '$CFG' not found"
exit 15
fi
CFG="$CFG.cfg"
fi
fi
CFG=`readlink -f "$CFG"`
if ! test -x $BOX; then
echo "$BOX not found or can't be started"
exit 20
fi
NAME=`basename $CFG .cfg`
PID=$PID_DIR/$NAME.pid
SCFG=$CONFIG_DIR/$NAME
RUNDIR=$SNAPSHOT_DIR/$NAME
LOG=$LOG_DIR/$NAME.log
LOGGER="exec /usr/lib/tarantool/logger $LOG"
SOCKETS=`grep \
'^[[:space:]]*\(opt[[:space:]]\+\)\?file_descriptors[[:space:]]*=[[:space:]]*[[:digit:]]\+' $CFG \
| tail -n 1 \
| sed 's/[^[:digit:]]//g'`
if test -z $SOCKETS; then
SOCKETS=1023
fi
if ! test -x $PID_DIR; then
install -otarantool -gtarantool -d -m0750 $PID_DIR
fi
SSDARGS_NO_PID="--quiet --chdir $RUNDIR --chuid tarantool --exec"
SSDARGS="--pidfile $PID $SSDARGS_NO_PID"
if [ $SOCKETS -gt 1024 -a $SOCKETS -lt 65000 ]; then
ulimit -n $SOCKETS
fi
ulimit -c unlimited
comment_str="#### - commented by init script"
sed "s/^[[:space:]]*file_descriptors.*/# & $comment_str/" $CFG > $SCFG
echo "pid_file = $PID" >> $SCFG
echo "logger = \"$LOGGER\"" >> $SCFG
grep '^[[:space:]]*admin_port[[:space:]]*=' $CFG |tail -n 1 >> $SCFG
grep '^[[:space:]]*primary_port[[:space:]]*=' $CFG |tail -n 1 >> $SCFG
$BOX -c $SCFG -v --check-config
if [ ! -d $RUNDIR ]; then
install -d -otarantool -gtarantool -m0750 $RUNDIR
cd $RUNDIR
if ! $SSD --start $SSDARGS $BOX -- --init-storage -v -c $SCFG;
then
rm -fr $RUNDIR
exit 25
fi
fi
if [ $ACTION = 'start' ]; then
echo -n " Starting '$NAME' ... "
else
echo -n " Stopping '$NAME' ... "
SSDARGS="--retry 15 $SSDARGS"
fi
if $SSD --$ACTION $SSDARGS $BOX -- -B -v -c $SCFG; then
echo "ok"
else
ret=$?
if [ $ret -eq 1 ]; then
if [ $ACTION = 'start' ]; then
echo "already started"
else
echo "already stoppped"
fi
else
echo "failed"
fi
fi
|