16 Star 53 Fork 13

DiDi-opensource/sgt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
control 1.68 KB
一键复制 编辑 原始数据 按行查看 历史
Ulric Qin 提交于 2018-10-12 13:22 . push to github
#!/bin/bash
CWD=$(cd $(dirname $0)/; pwd)
start()
{
if [ $(ps aux|grep -v grep|grep '/usr/local/sgd/bin/sgd' -c) -gt 0 ]; then
echo "already started"
exit 0
fi
DEV=${SGD_DEV:-0}
if [ "x$DEV" = "x1" ]; then
# in dev
$CWD/bin/sgd -s http://100.64.8.7:80 -d
else
# in prod
mkdir -p $CWD/log
nohup $CWD/bin/sgd -s http://100.64.8.7:80 &> $CWD/log/app.log &
fi
}
stop()
{
DEV=${SGD_DEV:-0}
if [ "x$DEV" = "x1" ]; then
# in dev
ps aux|grep -v grep|grep '/usr/local/sgd/bin/sgd'|awk '{print $1}'|xargs kill && echo "sgd killed"
ps aux|grep -v grep|grep '/usr/local/sgd/bin/sga'|awk '{print $1}'|xargs kill && echo "sga killed"
if [ $(ps aux|grep -v grep|grep '/usr/local/sgd/bin/sg' -c) -ne 0 ]; then
echo "cannot stop sgd and sga"
exit 1
fi
else
# in prod
ps aux|grep -v grep|grep '/usr/local/sgd/bin/sgd'|awk '{print $1}'|xargs kill && echo "sgd killed"
fi
}
build()
{
cd $CWD/sga && go build
cd $CWD/sgd && go build
}
pack()
{
goos=$1
goarch=$2
ver=$3
rm -rf $CWD/build && mkdir -p $CWD/build/bin && cp $CWD/control $CWD/build
cd $CWD/sga && GOOS=$goos GOARCH=$goarch go build && cp sga $CWD/build/bin/sga
cd $CWD/sgd && GOOS=$goos GOARCH=$goarch go build && cp sgd $CWD/build/bin/sgd
cd $CWD/build && tar zcvf $CWD/sgd-${ver}_${goos}_${goarch}.tar.gz control bin
}
release()
{
if [ ! -f uuid.url ]; then
echo "file uuid.url not found"
exit 1
fi
url=$(cat uuid.url | head -n 1)
sed -i "s|UUID_URL|$url|g" sgd/config/config.go
build
v=$($CWD/sgd/sgd -v)
pack linux 386 $v
pack linux amd64 $v
}
case "$1" in
start)
start
;;
stop)
stop
;;
build)
build
;;
release)
release
;;
*)
echo $"Usage: $0 {start|stop|build|release}"
esac
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/didiopensource/sgt.git
git@gitee.com:didiopensource/sgt.git
didiopensource
sgt
sgt
master

搜索帮助