Fetch the repository succeeded.
This action will force synchronization from sjqzhang/go-fastdfs, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
#!/bin/bash
WORKSPACE=$(cd $(dirname $0)/; pwd)
cd $WORKSPACE
mkdir -p log conf
module=
appname=$(basename $WORKSPACE)
## 注意:这里每个应用的启动命令是不一样的,
## 启动命令必须在前端运行(即不需要nohup)运行,
## 系统会自动加上nohup运行
## 例如:run_cmd=java -jar spring-hello.jar
run_cmd="./fileserver server"
conf=conf/cfg.json
pidfile=conf/app.pid
logfile=log/app.log
function check_pid() {
if [ -f $pidfile ];then
pid=`cat $pidfile`
if [ -n $pid ]; then
running=`ps -p $pid|grep -v "PID TTY" |wc -l`
return $running
fi
fi
return 0
}
#应用发布接口
function deploy() {
#自定义发布
#例如修改配置,移动文件夹等。。。
echo "请修改deploy接口,以满足你的发布需求。"
}
#应用启动接口
function start() {
check_pid
running=$?
if [ $running -gt 0 ];then
echo -n "$appname now is running already, pid="
cat $pidfile
return 1
fi
nohup $run_cmd &> $logfile &
echo $! > $pidfile
#echo "$appname started..., pid=$!"
sleep 3
status
}
#停止应用接口
function stop() {
pid=`cat $pidfile`
kill $pid
echo "$appname stoped..."
}
function restart() {
stop
sleep 1
start
}
#应用状态检测接口
function status() {
check_pid
running=$?
if [ $running -gt 0 ];then
echo -n "$appname now is running, pid="
cat $pidfile
#注意:以下输出不能修改,程序会自动根据这个输出做状态判断
echo "app_status:running"
else
#注意:以下输出不能修改,程序会自动根据这个输出做状态判断
echo "$appname is stoped"
echo "app_status:stoped"
fi
}
function tailf() {
timeout 50 tail -f $logfile
}
#应用构建接口
function build() {
# 注意:如果需要定制编译命令,可以修改这里
git log -1 --pretty=%h > gitversion
if [[ -f ./build.sh ]];then
sh ./build.sh #custom
elif [[ -f ./pom.xml ]];then
mvn install #java
elif [[ -f ./package.json ]];then
npm install #node
npm run product
fi
if [ $? -ne 0 ]; then
exit $?
fi
}
function pack() {
build
version=`cat gitversion`
file_list="control $appname"
tar zcf $appname-$version.tar.gz gitversion $file_list
}
function packbin() {
build
git log -1 --pretty=%h > gitversion
version=`cat gitversion`
tar zcvf $appname-bin-$version.tar.gz $appname gitversion
}
function help() {
echo "$0 start|stop|restart|status|tail|build|pack|deploy|help"
}
if [ "$1" == "" ]; then
help
elif [ "$1" == "stop" ];then
stop
elif [ "$1" == "start" ];then
start
elif [ "$1" == "build" ];then
build
elif [ "$1" == "deploy" ];then
deploy
elif [ "$1" == "restart" ];then
restart
elif [ "$1" == "pack" ];then
pack
elif [ "$1" == "status" ];then
status
elif [ "$1" == "tail" ];then
tailf
else
help
fi
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。