代码拉取完成,页面将自动刷新
#!/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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。