线上环境集群storage节点启动脚本
#!/bin/bash
#chkconfig: 2345 15 85
#description:fastdfs-storage-node start/stop
. /etc/init.d/functions
uid=`id|cut -d"(" -f1|awk -F"=" '{print $2}'`
cmd=/usr/local/sandai/tfdfs/bin/fdfs_storaged
fdfsstorage_config=/usr/local/sandai/tfdfs/conf/storage.conf
fdfsstorage_pid=`netstat -tlnp|grep fdfs|awk -F"[/ ]+" '/fdfs_storaged/{printf "pid %s\n",$7}'`
status=`ps -ef|grep fdfs_storaged|grep -v grep|wc -l`
prog=`basename $0`
lockfile=/var/lock/subsys/fastdfs-storage
[ $uid -ne 0 ] && exit 1
[ -x $cmd ] || exit 1
function start_storage() {
$cmd $fdfsstorage_config
retval=$?
if [ $retval -eq 0 ];then
touch $lockfile
action "starting fastdfs-storage" /bin/true
else
action "starting fastdfs-storage" /bin/fasle
fi
return $retval
}
function stop_storage() {
$cmd $fdfsstorage_config stop
retval=$?
if [ $retval -eq 0 ];then
/bin/rm $lockfile
action "stopping fastdfs-storage" /bin/true
else
action "stopping fastdfs-storage" /bin/fasle
fi
return $retval
}
function restart_storage() {
stop_storage
sleep 2
start_storage
}
function status_storage() {
if [ $status -eq 0 ];then
echo $prog is not running...
else
echo $prog ${fdfsstorage_pid} is running...
fi
}
case "$1" in
start)
start_storage
;;
stop)
stop_storage
;;
restart)
restart_storage
;;
status)
status_storage
;;
*)
echo "USAGE:$0 {start|stop|restart|status}"
exit 2
esac