[fix] fix the bug of container deployment failure

This commit is contained in:
tjq 2020-06-24 21:27:16 +08:00
parent 24d098d863
commit 606d693e3f
6 changed files with 11 additions and 20 deletions

View File

@ -65,6 +65,7 @@ if [ "$startup" = "y" ] || [ "$startup" = "Y" ]; then
-p 7700:7700 -p 10086:10086 -p 5001:5005 -p 10001:10000 \
-e JVMOPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=10000 -Dcom.sun.management.jmxremote.rmi.port=10000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" \
-e PARAMS="--spring.profiles.active=pre" \
-e TZ="Asia/Shanghai" \
-v ~/docker/powerjob-server:/root/powerjob-server -v ~/.m2:/root/.m2 \
tjqq/powerjob-server:$version
sleep 1

View File

@ -1,12 +0,0 @@
#!/bin/sh
# 一键部署脚本,请勿挪动脚本
cd `dirname $0`/../.. || exit
echo "================== 构建 jar =================="
mvn clean package -DskipTests -Pdev -e -U
echo "================== 拷贝 jar =================="
/bin/cp -rf powerjob-server/target/*.jar others/powerjob-server.jar
ls -l others/powerjob-server.jar
echo "================== debug 模式启动 =================="
nohup java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar others/powerjob-server.jar > powerjob-server.log &
sleep 100
tail --pid=$$ -f -n 1000 others/powerjob-server.log

View File

@ -26,7 +26,7 @@ docker run -d \
--name powerjob-server \
-p 7700:7700 -p 10086:10086 -p 5001:5005 -p 10001:10000 \
-e JVMOPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=10000 -Dcom.sun.management.jmxremote.rmi.port=10000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" \
-e PARAMS="--spring.profiles.active=product --spring.datasource.core.jdbc-url=jdbc:mysql://139.224.83.134:3306/powerjob-product?useUnicode=true&characterEncoding=UTF-8 --spring.data.mongodb.uri=mongodb://139.224.83.134:27017/powerjob-product" \
-e PARAMS="--spring.profiles.active=product --spring.datasource.core.jdbc-url=jdbc:mysql://remotehost:3306/powerjob-product?useUnicode=true&characterEncoding=UTF-8 --spring.data.mongodb.uri=mongodb://remotehost:27017/powerjob-product" \
-v ~/docker/powerjob-server:/root/powerjob-server -v ~/.m2:/root/.m2 \
tjqq/powerjob-server:latest
sleep 60

View File

@ -13,7 +13,6 @@ ENV M2_HOME=/opt/powerjob-maven
# 设置时区
ENV TZ=Asia/Shanghai
RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# 设置其他环境变量
ENV APP_NAME=powerjob-server

View File

@ -3,7 +3,7 @@ logging.config=classpath:logback-product.xml
####### 数据库配置 #######
spring.datasource.core.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.core.jdbc-url=jdbc:mysql://remotehost:3391/powerjob-pre?useUnicode=true&characterEncoding=UTF-8
spring.datasource.core.jdbc-url=jdbc:mysql://remotehost:3306/powerjob-pre?useUnicode=true&characterEncoding=UTF-8
spring.datasource.core.username=root
spring.datasource.core.password=No1Bug2Please3!
spring.datasource.core.hikari.maximum-pool-size=20

View File

@ -7,6 +7,7 @@ import com.github.kfcfans.powerjob.common.model.DeployedContainerInfo;
import com.github.kfcfans.powerjob.common.request.ServerDeployContainerRequest;
import com.github.kfcfans.powerjob.common.request.WorkerNeedDeployContainerRequest;
import com.github.kfcfans.powerjob.common.response.AskResponse;
import com.github.kfcfans.powerjob.common.utils.CommonUtils;
import com.github.kfcfans.powerjob.worker.OhMyWorker;
import com.github.kfcfans.powerjob.worker.common.utils.AkkaUtils;
import com.github.kfcfans.powerjob.worker.common.utils.OmsWorkerFileUtils;
@ -67,7 +68,7 @@ public class OmsContainerFactory {
deployContainer(deployRequest);
}
}catch (Exception e) {
log.error("[OmsContainer-{}] deployed container failed, exception is {}", containerId, e.toString());
log.error("[OmsContainer-{}] get container failed, exception is {}", containerId, e.toString());
}
return CARGO.get(containerId);
@ -92,11 +93,11 @@ public class OmsContainerFactory {
return;
}
try {
String filePath = OmsWorkerFileUtils.getContainerDir() + containerId + "/" + version + ".jar";
// 下载Container到本地
File jarFile = new File(filePath);
// 下载Container到本地
String filePath = OmsWorkerFileUtils.getContainerDir() + containerId + "/" + version + ".jar";
File jarFile = new File(filePath);
try {
if (!jarFile.exists()) {
FileUtils.forceMkdirParent(jarFile);
FileUtils.copyURLToFile(new URL(request.getDownloadURL()), jarFile, 5000, 300000);
@ -118,6 +119,8 @@ public class OmsContainerFactory {
}catch (Exception e) {
log.error("[OmsContainer-{}] deployContainer(name={},version={}) failed.", containerId, containerName, version, e);
// 如果部署失败则删除该 jar本次失败可能是下载jar出错导致不删除会导致这个版本永久无法重新部署
CommonUtils.executeIgnoreException(() -> FileUtils.forceDelete(jarFile));
}
}