美文网首页
Tokyo Cabinet和Tokyo Tyrant

Tokyo Cabinet和Tokyo Tyrant

作者: 不排版 | 来源:发表于2018-03-27 18:06 被阅读8次

启动
tserver -host 127.0.0.1 -port 11111 -thnum 8 -dmn -pid /opt/ttdata/ttdata.pid -log /opt/ttdata/ttserver.log -le -ulog /opt/ttdata/ -ulim 128m -sid 1 -rts /opt/ttdata/ttdata.rts /opt/ttdata/database.tch


image.png

////////////////////多实例脚本////////////////////

! /bin/sh

----------------------------------------------------------------

Startup script for the server of Tokyo Tyrant

----------------------------------------------------------------

configuration variables

prog="ttservctl"
cmd="ttserver"
port="$3"
basedir="$1/$3"
pidfile="$basedir/pid"
logfile="$basedir/$port.log"
ulogdir="$basedir/$port.ulog"
ulimsiz="256m"
if [ $# -eq 4 ]; then
sid="$4";
else
sid= date +%s%N
fi

mhost="remotehost1"

mport="1978"

rtsfile="$basedir/rts"

dbname="$basedir/casket.tch#bnum=1000000"
retval=0

setting environment variables

LANG=C
LC_ALL=C
PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin"
export LANG LC_ALL PATH

start the server

start(){
printf 'Starting the server of Tokyo Tyrant\n'
mkdir -p "$basedir"
if [ -z "$basedir" ] || [ -z "$port" ] || [ -z "$pidfile" ] || [ -z "$dbname" ] ; then
printf 'Invalid configuration\n'
retval=1
elif ! [ -d "$basedir" ] ; then
printf 'No such directory: %s\n' "$basedir"
retval=1
elif [ -f "$pidfile" ] ; then
pid=cat "$pidfile"
printf 'Existing process: %d\n' "$pid"
retval=1
else
cmd="$cmd -port $port -dmn -pid $pidfile"
if [ -n "$logfile" ] ; then
cmd="$cmd -log $logfile"
fi
if [ -n "$ulogdir" ] ; then
mkdir -p "$ulogdir"
cmd="$cmd -ulog $ulogdir"
fi
if [ -n "$ulimsiz" ] ; then
cmd="$cmd -ulim $ulimsiz"
fi
if [ -n $sid ] ; then
cmd="$cmd -sid $sid"
fi
if [ -n "$mhost" ] ; then
cmd="$cmd -mhost $mhost"
fi
if [ -n "$mport" ] ; then
cmd="$cmd -mport $mport"
fi
if [ -n "$rtsfile" ] ; then
cmd="$cmd -rts $rtsfile"
fi
cmd="$cmd -uas "
printf "Executing: %s\n" "$cmd"
cmd="$cmd $dbname"
$cmd
if [ "$?" -eq 0 ] ; then
printf 'Done\n'
else
printf 'The server could not started\n'
retval=1
fi
fi
}

stop the server

stop(){
printf 'Stopping the server of Tokyo Tyrant\n'
if [ -f "$pidfile" ] ; then
pid=cat "$pidfile"
printf "Sending the terminal signal to the process: %s\n" "$pid"
kill -TERM "$pid"
c=0
while true ; do
sleep 0.1
if [ -f "$pidfile" ] ; then
c=expr $c + 1
if [ "$c" -ge 100 ] ; then
printf 'Hanging process: %d\n' "$pid"
retval=1
break
fi
else
printf 'Done\n'
break
fi
done
else
printf 'No process found\n'
retval=1
fi
}

send HUP to the server for log rotation

hup(){
printf 'Sending HUP signal to the server of Tokyo Tyrant\n'
if [ -f "$pidfile" ] ; then
pid=cat "$pidfile"
printf "Sending the hangup signal to the process: %s\n" "$pid"
kill -HUP "$pid"
printf 'Done\n'
else
printf 'No process found\n'
retval=1
fi
}

check permission

if [ -d "$basedir" ] && ! touch "$basedir/$$" >/dev/null 2>&1
then
printf 'Permission denied\n'
exit 1
fi
rm -f "$basedir/$$"

dispatch the command

case "$2" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
hup)
hup
;;
*)
printf 'Usage: ./ttserver /opt/ttdata start 1234 3 ' "$prog"
exit 1
;;
esac

exit

exit "$retval"

END OF FILE

相关文章

  • Tokyo Cabinet和Tokyo Tyrant

    启动tserver -host 127.0.0.1 -port 11111 -thnum 8 -dmn -pid ...

  • Tokyo, Tokyo

    不知道有多少人因为这部剧而被这座城所吸引—《东京爱情故事》,也不知道有多少人未曾看过这部剧,至少这部青春偶像剧伴随...

  • The Charm of black and white and

    A review about Tokyo Story Tokyo Story is a fabulous Japa...

  • Tokyo

    因为基本只有三天行程,所以不会写很长,估计不会超过我之前修手机的经历那篇,大家放心我没那么多情绪要宣泄了。 ...

  • tokyo

  • Tokyo to Osaka

    Tokyo to Osaka 以往对日本的认知在手机上,在网络的信息中,第一次踏上这片国度的时候,有些地方还是挺触...

  • Tokyo R

    2018年7月 ,日本东京举行的TokyoR用户组第七十一次会议。这个为期一天的小型会议吸引了200多名与会者参加...

  • Hi Tokyo

    那些见过的人,走过的路,看过的风景…… 每张照片背后,都有故事 到成田机场,已是下午6:30,路过一面大落地窗,随...

  • Dairy in Tokyo

    Day1 成田机场→东京奥林匹克青少年中心 准确的说不算第一天吧,因为在机场待了一个下午。。。 首先想说的是飞机窗...

  • Tokyo Disneyland

    最近连续的加班,好不容易憋着一口气才撑到了周末。通常工作以外的时间,我的大脑处于休眠状态,不能正常思考。 而忙碌中...

网友评论

      本文标题:Tokyo Cabinet和Tokyo Tyrant

      本文链接:https://www.haomeiwen.com/subject/snyscftx.html