Watch 4 Star 26 Fork 7

jc3wish / BifrostGoApache-2.0

Join us
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
Bifrost ---- 面向生产环境的 MySQL 同步到Redis,MongoDB等服务的异构中间件 spread retract

http://www.xbifrost.com/

Clone or download
Bifrost-server 3.09 KB
Copy Edit Web IDE Raw Blame History
#!/bin/sh
#Copyright [2018] [jc3wish]
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#http://www.apache.org/licenses/LICENSE-2.0
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
bin_dir=
pid_file=
config_file=
mode=$1 # start or stop or restart
basepath=$(cd `dirname $0`; pwd)
__readINI () {
INIFILE=$1; SECTION=$2; ITEM=$3;
_readIni=`cat $INIFILE | awk 'BEGIN{FS="=";OFS=":";}/\'$SECTION'\]/,/\[.*[^('$SECTION')].*\]/{gsub(/[[:blank:]]*/,"",$1);if(NF==2 && $1=="'$ITEM'"){gsub(/^[[:blank:]]*/,"",$2);gsub(/[[:blank:]]*$/,"",$2);print $2;}}'`
echo "${_readIni}"
}
if test -z "$bin_dir"
then
bin_dir="$basepath"
fi
if test -z "$config_file"
then
config_file="$basepath/etc/Bifrost.ini"
fi
if test -z "$pid_file"
then
pid_file=$(__readINI $config_file Bifrostd pid);
fi
if test -z "$pid_file"
then
pid_file="$basepath/Bifrost.pid"
fi
case "$mode" in
'start')
# Start daemon
#echo "Starting Bifrost"
if test -x $bin_dir/Bifrost
then
$bin_dir/Bifrost -d true -config "$config_file" -pid "$pid_file"
else
echo "Couldn't find Bifrost server ($bin_dir/Bifrost)"
exit 1
fi
exit 0
;;
'stop')
# Stop daemon. We use a signal here to avoid having to know the
if test -s "$pid_file"
then
bifrost_pid=`cat "$pid_file"`
if (kill -0 $bifrost_pid 2>/dev/null)
then
echo "Shutting down Bifrost"
kill $bifrost_pid
for i in 1 2 3
do
sleep 1
if !(kill -0 $bifrost_pid 2>/dev/null)
then
echo "server stop success"
exit 0
fi
done
echo "kill $bifrost_pid failed, retry please"
exit 1
else
echo "Bifrost server process #$bifrost_pid is not running!"
rm "$pid_file"
exit 1
fi
exit 0
else
echo "Bifrost server PID file could not be found!"
exit 1
fi
;;
'restart')
# Stop the service and regardless of whether it was
# running or not, start it again.
if ($0 stop); then
$0 start
else
echo "Failed to stop running server, so refusing to try to start."
exit 1
fi
;;
'status')
# First, check to see if pid file exists
if test -s "$pid_file" ; then
bifrost_pid=`cat "$pid_file"`
if kill -0 $bifrost_pid 2>/dev/null ; then
echo "Bifrost running ($bifrost_pid)"
exit 0
else
echo "Bifrost is not running, but PID file exists"
exit 1
fi
else
echo "PID file not exists"
exit 1
fi
;;
*)
# usage
basename=`basename "$0"`
echo "Usage: $basename {start|stop|restart|status} [ Bifrost server options ]"
exit 1
;;
esac
exit 0

Comment ( 0 )

Sign in for post a comment

Go
1
https://gitee.com/jc3wish/Bifrost.git
git@gitee.com:jc3wish/Bifrost.git
jc3wish
Bifrost
Bifrost
master

Help Search