Merge branch 'master' into docker_package
This commit is contained in:
commit
08946ec1b0
|
@ -326,8 +326,13 @@
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<excludes>
|
<excludes>
|
||||||
<!-- 排除生产环境配置 -->
|
<!-- 排除生产环境配置 -->
|
||||||
<exclude>application-prod.yml</exclude>
|
|
||||||
<exclude>application-bt.yml</exclude>
|
<exclude>application-bt.yml</exclude>
|
||||||
|
<exclude>application-dev.yml</exclude>
|
||||||
|
<exclude>application-hwx.yml</exclude>
|
||||||
|
<exclude>application-my.yml</exclude>
|
||||||
|
<exclude>application-prod.yml</exclude>
|
||||||
|
<exclude>application-show.yml</exclude>
|
||||||
|
<exclude>application-test.yml</exclude>
|
||||||
<exclude>application-xha.yml</exclude>
|
<exclude>application-xha.yml</exclude>
|
||||||
<!-- 排除flyway管理的sql -->
|
<!-- 排除flyway管理的sql -->
|
||||||
<exclude>db/*.sql</exclude>
|
<exclude>db/*.sql</exclude>
|
||||||
|
@ -363,7 +368,9 @@
|
||||||
<classpathPrefix>lib/</classpathPrefix>
|
<classpathPrefix>lib/</classpathPrefix>
|
||||||
</manifest>
|
</manifest>
|
||||||
<manifestEntries>
|
<manifestEntries>
|
||||||
<Class-Path>. lib/yawei-pso-${yawei-pso.version}.jar lib/contingencyplan-${contingencyplan.version}.jar</Class-Path>
|
<Class-Path>. lib/yawei-pso-${yawei-pso.version}.jar
|
||||||
|
lib/contingencyplan-${contingencyplan.version}.jar
|
||||||
|
</Class-Path>
|
||||||
</manifestEntries>
|
</manifestEntries>
|
||||||
</archive>
|
</archive>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package io.renren.common.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import io.renren.common.annotation.LogOperation;
|
||||||
|
import io.renren.common.utils.Result;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import okhttp3.ConnectionPool;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@Api(tags = "管理员后台")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin")
|
||||||
|
public class AdminController {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(AdminController.class);
|
||||||
|
private static final Integer CPUNUM = Runtime.getRuntime().availableProcessors();
|
||||||
|
private static final ExecutorService executor = Executors.newFixedThreadPool(CPUNUM);
|
||||||
|
|
||||||
|
private static final OkHttpClient client = new OkHttpClient().newBuilder()
|
||||||
|
.connectTimeout(1, TimeUnit.MINUTES)
|
||||||
|
.readTimeout(1, TimeUnit.MINUTES)
|
||||||
|
.connectionPool(new ConnectionPool(CPUNUM * 2, 2, TimeUnit.MINUTES))
|
||||||
|
.retryOnConnectionFailure(false)
|
||||||
|
.build(); // 下载更新包
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(value = "/update")
|
||||||
|
@ApiOperation("进行后台程序更新")
|
||||||
|
@LogOperation("进行后台程序更新")
|
||||||
|
public Result<String> update(String updateFile) {
|
||||||
|
return new Result<String>().ok("");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -59,14 +59,14 @@ spring:
|
||||||
database: 0
|
database: 0
|
||||||
host: 127.0.0.1
|
host: 127.0.0.1
|
||||||
port: 6379
|
port: 6379
|
||||||
password: # 密码(默认为空)
|
password: # 密码(默认为空)
|
||||||
timeout: 6000ms # 连接超时时长(毫秒)
|
timeout: 6000ms # 连接超时时长(毫秒)
|
||||||
jedis:
|
jedis:
|
||||||
pool:
|
pool:
|
||||||
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
|
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
|
||||||
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||||
max-idle: 10 # 连接池中的最大空闲连接
|
max-idle: 10 # 连接池中的最大空闲连接
|
||||||
min-idle: 5 # 连接池中的最小空闲连接
|
min-idle: 5 # 连接池中的最小空闲连接
|
||||||
activiti:
|
activiti:
|
||||||
check-process-definitions: false
|
check-process-definitions: false
|
||||||
resources:
|
resources:
|
||||||
|
@ -81,7 +81,7 @@ spring:
|
||||||
parser:
|
parser:
|
||||||
# 允许出现特殊字符和转义符
|
# 允许出现特殊字符和转义符
|
||||||
allow_unquoted_control_chars: true
|
allow_unquoted_control_chars: true
|
||||||
#允许出现单引号
|
# 允许出现单引号
|
||||||
allow_single_quotes: true
|
allow_single_quotes: true
|
||||||
|
|
||||||
fdfs:
|
fdfs:
|
||||||
|
|
|
@ -54,8 +54,13 @@
|
||||||
<include>domain/**</include>
|
<include>domain/**</include>
|
||||||
</includes>
|
</includes>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>application-prod.yml</exclude>
|
|
||||||
<exclude>application-bt.yml</exclude>
|
<exclude>application-bt.yml</exclude>
|
||||||
|
<exclude>application-dev.yml</exclude>
|
||||||
|
<exclude>application-hwx.yml</exclude>
|
||||||
|
<exclude>application-my.yml</exclude>
|
||||||
|
<exclude>application-prod.yml</exclude>
|
||||||
|
<exclude>application-show.yml</exclude>
|
||||||
|
<exclude>application-test.yml</exclude>
|
||||||
<exclude>application-xha.yml</exclude>
|
<exclude>application-xha.yml</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
|
|
|
@ -0,0 +1,117 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# $1: 参数$1是当前目录,即`pwd`,一般来说是/ava_app/platform/app
|
||||||
|
# $2: 参数$2是更新包的文件,一般为/ava_app/platform/app/upload/update/xxxwebapps.tar.gz
|
||||||
|
# $3: APP的名称。yhd
|
||||||
|
|
||||||
|
# 这里全部使用绝对路径,不要使用相对路径!!因为调用了其他脚本,可能发生路径问题。
|
||||||
|
|
||||||
|
# 变量声明
|
||||||
|
APP_DIR=$1
|
||||||
|
UPDATE_PACKAGE=$2
|
||||||
|
APP_NAME=$3
|
||||||
|
# 更新日志写在项目根目录中
|
||||||
|
LOG_FILE="${APP_DIR}/update.log"
|
||||||
|
|
||||||
|
|
||||||
|
# 删除系统生成的临时文件
|
||||||
|
#rm -rf /tmp/tomcat-*
|
||||||
|
#rm -rf /tmp/ehcache/*
|
||||||
|
|
||||||
|
|
||||||
|
# 将更新过程中出现的输出打印到日志文件中
|
||||||
|
rm -f $LOG_FILE
|
||||||
|
exec 1>$LOG_FILE 2>&1
|
||||||
|
|
||||||
|
# 参数校验
|
||||||
|
if [ -z "$APP_DIR" ] || [ -z "$UPDATE_PACKAGE" ] || [ -z "$APP_NAME" ]; then
|
||||||
|
echo "必要参数缺失"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$APP_DIR" = "/" ]; then
|
||||||
|
echo "APP_DIR 不能为 /"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$UPDATE_PACKAGE" ]; then
|
||||||
|
echo "平台更新包不存在"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# 停止程序,如果停止之后还有进程,那么直接杀死
|
||||||
|
sleep 5
|
||||||
|
sh ${APP_DIR}/renren-admin.sh stop
|
||||||
|
|
||||||
|
|
||||||
|
# 创建临时文件夹,用于解压更新包
|
||||||
|
rm -rf ${APP_DIR}/tmp
|
||||||
|
mkdir -p ${APP_DIR}/tmp
|
||||||
|
|
||||||
|
|
||||||
|
# 将更新包移动到tmp目录,重命名为app.tar.gz,然后解压
|
||||||
|
mv $UPDATE_PACKAGE ${APP_DIR}/tmp/app.tar.gz
|
||||||
|
tar -zxvf ${APP_DIR}/tmp/app.tar.gz -C ${APP_DIR}/tmp
|
||||||
|
chmod -R 766 ${APP_DIR}/tmp
|
||||||
|
|
||||||
|
|
||||||
|
# 更新指定的项目。
|
||||||
|
# 1. 如果备份是今天以前的则移除之前的备份,重新备份
|
||||||
|
# 2. 更新项目
|
||||||
|
# 如果项目的jar存在那么更新
|
||||||
|
if [ -f "${APP_DIR}/tmp/${APP_NAME}/${APP_NAME}.jar" ]; then
|
||||||
|
echo "正在更新 ${APP_NAME} 项目"
|
||||||
|
# 备份项目
|
||||||
|
b=0
|
||||||
|
if [ -d ${APP_DIR}/snapshot ]; then
|
||||||
|
b=`stat -c %Y ${APP_DIR}/snapshot`
|
||||||
|
else
|
||||||
|
mkdir -p ${APP_DIR}/snapshot/
|
||||||
|
fi
|
||||||
|
e=`date +%s`
|
||||||
|
p=$(($e-$b))
|
||||||
|
if [ $p -gt 86400 ]; then
|
||||||
|
echo "正在备份 ${APP_NAME} 项目"
|
||||||
|
# 删除文件夹,再重新创建,这样上面才可以检测时间
|
||||||
|
rm -rf ${APP_DIR}/snapshot
|
||||||
|
mkdir -p ${APP_DIR}/snapshot
|
||||||
|
# 备份lib、resources、jar
|
||||||
|
\cp -rf ${APP_DIR}/lib ${APP_DIR}/snapshot
|
||||||
|
\cp -rf ${APP_DIR}/resources ${APP_DIR}/snapshot
|
||||||
|
\cp -rf ${APP_DIR}/${APP_NAME}.jar ${APP_DIR}/snapshot
|
||||||
|
echo "${APP_NAME} 项目备份完成"
|
||||||
|
fi
|
||||||
|
# 更新项目
|
||||||
|
if [ -f "${APP_DIR}/tmp/${APP_NAME}/${APP_NAME}.version.replace" ]; then
|
||||||
|
echo "正在进行全量更新"
|
||||||
|
# 备份配置文件
|
||||||
|
mv -f ${APP_DIR}/resources/application-prod.yml ${APP_DIR}/application-prod.yml
|
||||||
|
# 移除lib、resources、jar
|
||||||
|
rm -rf ${APP_DIR}/lib
|
||||||
|
rm -rf ${APP_DIR}/resources
|
||||||
|
rm -rf ${APP_DIR}/${APP_NAME}.jar
|
||||||
|
# 创建resources将配置文件copy回去
|
||||||
|
mkdir -p ${APP_DIR}/resources
|
||||||
|
mv -f ${APP_DIR}/application-prod.yml ${APP_DIR}/resources/application-prod.yml
|
||||||
|
rm -rf ${APP_DIR}/tmp/${APP_NAME}/resources/application-prod.yml
|
||||||
|
else
|
||||||
|
# 这里不用移除前端静态资源,前端静态资源独立部署
|
||||||
|
echo "正在进行增量更新"
|
||||||
|
rm -rf ${APP_DIR}/lib/ava-*.jar
|
||||||
|
fi
|
||||||
|
\cp -rf ${APP_DIR}/tmp/${APP_NAME}/lib ${APP_DIR}/
|
||||||
|
\cp -rf ${APP_DIR}/tmp/${APP_NAME}/resources ${APP_DIR}/
|
||||||
|
\cp -rf ${APP_DIR}/tmp/${APP_NAME}/${APP_NAME}.jar ${APP_DIR}/
|
||||||
|
echo "${APP_NAME} 项目更新完成"
|
||||||
|
else
|
||||||
|
echo "${APP_NAME} 项目程序不存在"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# 移除更新包以及更新的项目
|
||||||
|
rm -rf ${APP_DIR}/tmp/*
|
||||||
|
|
||||||
|
|
||||||
|
# 重启平台
|
||||||
|
sh ${APP_DIR}/renren-admin.sh start
|
||||||
|
exit 0
|
Loading…
Reference in New Issue