zhangqiankun 3 年之前
父节点
当前提交
eaa4e519d0

+ 34 - 0
job-admin/Dockerfile

@@ -0,0 +1,34 @@
+#构建此镜像的基础镜像
+FROM registry.persagy.com/base/centos:v-jdk1.8
+#指定作者名称
+MAINTAINER lijie<lijie@persagy.com>
+
+#定义标签属性
+LABEL tier=backend
+LABEL product=integrated
+LABEL project=job-admin
+LABEL name=integrated-job
+
+#设置环境变量
+ENV TZ Asia/Shanghai
+#ARG 可以接收docker build命令中以--build-arg 指定的参数
+ENV WORKER_HOME /mnt/integrated/job-admin
+
+#执行的命令
+RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime	&& echo 'Asia/Shanghai' > /etc/timezone
+
+RUN mkdir -p $WORKER_HOME/config
+
+#复制文件到容器内
+COPY target/*.jar $WORKER_HOME/app.jar
+COPY entrypoint.sh $WORKER_HOME/
+#COPY version.txt $WORKER_HOME/
+#COPY config $WORKER_HOME/config
+#设置工作目录
+WORKDIR $WORKER_HOME
+
+#查看上述复制的文件,是否复制成功
+RUN ls
+
+#启动执行
+ENTRYPOINT ["sh","./entrypoint.sh"]

+ 3 - 0
job-admin/entrypoint.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+echo "entrypoint run..."
+java -jar $JAVA_OPTS -Dfile.encoding=UTF-8 -Dconsole.encoding=UTF-8 -Dserver.port=$SERVER_PORT -Deureka.client.service-url.defaultZone=$EUREKA_CLIENT_DEFAULT_ZONE -Dspring.cloud.config.profile=$SPRING_CLOUD_CONFIG_PROFILE -Dspring.cloud.config.uri=$SPRING_CLOUD_CONFIG_URI app.jar

+ 133 - 5
job-admin/pom.xml

@@ -8,7 +8,6 @@
 	</parent>
 	<artifactId>job-admin</artifactId>
 	<packaging>jar</packaging>
-
 	<dependencies>
 
 		<!-- starter-web:spring-webmvc + autoconfigure + logback + yaml + tomcat -->
@@ -66,17 +65,53 @@
 			<groupId>com.xuxueli</groupId>
 			<artifactId>job-core</artifactId>
 			<version>${project.parent.version}</version>
+			<exclusions>
+				<exclusion>
+					<artifactId>javassist</artifactId>
+					<groupId>org.javassist</groupId>
+				</exclusion>
+				<exclusion>
+					<artifactId>poi-ooxml-schemas</artifactId>
+					<groupId>org.apache.poi</groupId>
+				</exclusion>
+				<exclusion>
+					<artifactId>mybatis</artifactId>
+					<groupId>org.mybatis</groupId>
+				</exclusion>
+				<exclusion>
+					<artifactId>poi</artifactId>
+					<groupId>org.apache.poi</groupId>
+				</exclusion>
+				<exclusion>
+					<artifactId>commons-logging</artifactId>
+					<groupId>commons-logging</groupId>
+				</exclusion>
+				<exclusion>
+					<artifactId>poi-ooxml</artifactId>
+					<groupId>org.apache.poi</groupId>
+				</exclusion>
+			</exclusions>
 		</dependency>
 
 		<!--  knife4j for swagger -->
-		<dependency>
+		<!--<dependency>
 			<groupId>com.github.xiaoymin</groupId>
 			<artifactId>knife4j-spring-boot-starter</artifactId>
 			<version>${knife4j-spring-boot-starter.version}</version>
-		</dependency>
+		</dependency>-->
 		
 	</dependencies>
 
+	<properties>
+		<docker.registry>labisenlin.persagy.com</docker.registry>
+		<docker.plugin.version>0.32.0</docker.plugin.version>
+		<docker.username>admin</docker.username>
+		<docker.password>1qaz@WSX</docker.password>
+		<docker.namespace>integrated-public</docker.namespace>
+		<docker.host>http://192.168.52.100:2375</docker.host>
+		<docker.tcp.host>tcp://192.168.52.100:2375</docker.tcp.host>
+	</properties>
+
 	<build>
 		<plugins>
 			<plugin>
@@ -91,12 +126,12 @@
 				</executions>
 			</plugin>
 			<!-- docker -->
-			<plugin>
+			<!--<plugin>
 				<groupId>com.spotify</groupId>
 				<artifactId>docker-maven-plugin</artifactId>
 				<version>0.4.13</version>
 				<configuration>
-					<!-- made of '[a-z0-9-_.]' -->
+					&lt;!&ndash; made of '[a-z0-9-_.]' &ndash;&gt;
 					<imageName>${project.artifactId}:${project.version}</imageName>
 					<dockerDirectory>${project.basedir}</dockerDirectory>
 					<resources>
@@ -107,6 +142,99 @@
 						</resource>
 					</resources>
 				</configuration>
+			</plugin>-->
+			<plugin>
+				<groupId>io.fabric8</groupId>
+				<artifactId>docker-maven-plugin</artifactId>
+				<version>${docker.plugin.version}</version>
+				<!--全局配置-->
+				<configuration>
+					<!--这一部分是为了实现对远程docker容器的控制-->
+					<!--docker主机地址,用于完成docker各项功能,注意是tcp不是http!-->
+					<dockerHost>${docker.tcp.host}</dockerHost>
+					<!--docker远程访问所需证书地址,如果docker远程主机没有启用TLS验证则不需要配证书-->
+					<certPath>${project.basedir}/docker/ssh</certPath>
+					<!--这一部分是为了实现docker镜像的构建和推送-->
+					<!--registry地址,用于推送,拉取镜像,我这里用的是阿里的registry-->
+					<registry>${docker.registry}</registry>
+					<!--认证配置,用于私有registry认证,如果忘记了可以去阿里的registry查看-->
+					<authConfig>
+						<push>
+							<username>${docker.username}</username>
+							<password>${docker.password}</password>
+						</push>
+					</authConfig>
+
+					<!--镜像相关配置,支持多镜像-->
+					<images>
+						<!-- 单个镜像配置 -->
+						<image>
+							<!--镜像名(含版本号)-->
+							<name>${docker.registry}/${docker.namespace}/${project.name}:${project.version}</name>
+							<!--别名:用于容器命名和在docker-compose.yml文件只能找到对应名字的配置-->
+							<alias>${project.name}</alias>
+							<!--<copy>
+								<entries>
+									<entry>
+										&lt;!&ndash; The container directory to copy &ndash;&gt;
+										<containerPath>/mnt/integrated/job-admin/app.jar</containerPath>
+										<hostDirectory>${project.basedir}/target/*.jar</hostDirectory>
+									</entry>
+								</entries>
+							</copy>-->
+							<!--镜像build相关配置-->
+							<build>
+								<!--使用dockerFile文件-->
+								<dockerFile>${project.basedir}/Dockerfile</dockerFile>
+								<!--<from>registry.persagy.com/base/centos:v-jdk1.8</from>
+								<workdir>/mnt/integrated/job-admin</workdir>
+								<env>
+									<TZ>Asia/Shanghai</TZ>
+									<WORKER_HOME>/mnt/integrated/job-admin</WORKER_HOME>
+								</env>
+								<labels>
+									<tier>backend</tier>
+									<product>integrated</product>
+									<project>job-admin</project>
+									<name>job-admin</name>
+								</labels>
+								<runCmds>
+									<run>ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime</run>
+									<run>echo 'Asia/Shanghai' > /etc/timezone</run>
+									<run>mkdir -p $WORKER_HOME/config</run>
+								</runCmds>
+								&lt;!&ndash;相当于Dockerfile中的entryPoint &ndash;&gt;
+								<entryPoint>
+									<exec>
+										<arg>java</arg>
+										<arg>-jar</arg>
+										<arg>$JAVA_OPTS</arg>
+										<arg>-Dfile.encoding=UTF-8</arg>
+										<arg>-Dconsole.encoding=UTF-8</arg>
+										<arg>-Dserver.port=$SERVER_PORT</arg>
+										<arg>app.jar</arg>
+									</exec>
+								</entryPoint>
+                                <assembly>
+                                    &lt;!&ndash;生成的模式,默认为dir&ndash;&gt;
+                                    <mode>dir</mode>
+                                    &lt;!&ndash;输出的目录,在镜像容器中的位置及编译生成的jar文件名称&ndash;&gt;
+                                    <targetDir>$WORKER_HOME/app.jar</targetDir>
+                                    &lt;!&ndash;&ndash;&gt;
+                                    <descriptorRef>project</descriptorRef>
+                                </assembly>-->
+							</build>
+						</image>
+					</images>
+				</configuration>
+				<dependencies>
+					<!--该插件需要这个依赖-->
+					<dependency>
+						<groupId>commons-codec</groupId>
+						<artifactId>commons-codec</artifactId>
+						<version>1.11</version>
+					</dependency>
+				</dependencies>
 			</plugin>
 		</plugins>
 	</build>

+ 2 - 4
job-admin/src/main/java/com/xxl/job/admin/controller/custom/CustomInfoController.java

@@ -30,8 +30,6 @@ import com.xxl.job.core.biz.model.ReturnT;
 import com.xxl.job.core.constant.CommonConstant;
 import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
 
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
 
 /**
  * 暴露接口
@@ -41,7 +39,7 @@ import io.swagger.annotations.ApiOperation;
  * @date 2021年9月24日 下午2:37:55
  */
 @RestController
-@Api(tags = "任务触发点设置")
+//@Api(tags = "任务触发点设置")
 @RequestMapping(value = "/customInfo", method = {RequestMethod.POST})
 public class CustomInfoController {
 
@@ -152,7 +150,7 @@ public class CustomInfoController {
 	/************************************************ 字典值查询  *********************************************/
 	
 	@RequestMapping("/dictQuery")
-	@ApiOperation(value = "字典值查询")
+	//@ApiOperation(value = "字典值查询")
 	public String remove(@RequestBody @Validated DictQuery query) {
 		JSONObject content = new JSONObject();
 		if (CommonConstant.EXECUTOR_ROUTE_STRATEGY.equals(query.getQueryType())) {

+ 2 - 5
job-admin/src/main/java/com/xxl/job/admin/controller/custom/OldCustomInfoController.java

@@ -29,9 +29,6 @@ import com.xxl.job.core.biz.model.ReturnT;
 import com.xxl.job.core.constant.CommonConstant;
 import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
 
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-
 /**
  * 暴露接口
  * @version 1.0.0
@@ -40,7 +37,7 @@ import io.swagger.annotations.ApiOperation;
  * @date 2021年9月24日 下午2:37:55
  */
 @RestController
-@Api(tags = "任务触发点设置")
+//@Api(tags = "任务触发点设置")
 @RequestMapping(value = "/admin/customJobInfo", method = {RequestMethod.POST})
 public class OldCustomInfoController {
 
@@ -138,7 +135,7 @@ public class OldCustomInfoController {
 	/************************************************ 字典值查询  *********************************************/
 	
 	@RequestMapping("/dictQuery")
-	@ApiOperation(value = "字典值查询")
+	//@ApiOperation(value = "字典值查询")
 	public String remove(@RequestBody @Validated DictQuery query) {
 		JSONObject content = new JSONObject();
 		if (CommonConstant.EXECUTOR_ROUTE_STRATEGY.equals(query.getQueryType())) {

+ 2 - 4
job-admin/src/main/java/com/xxl/job/admin/core/model/DictQuery.java

@@ -3,8 +3,6 @@ package com.xxl.job.admin.core.model;
 import javax.validation.constraints.NotBlank;
 
 import groovy.transform.ToString;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -18,11 +16,11 @@ import lombok.Setter;
 @Getter
 @Setter
 @ToString
-@ApiModel(description = "字典查询请求类")
+//@ApiModel(description = "字典查询请求类")
 public class DictQuery {
 	
 	@NotBlank(message = "查询类型不可为空")
-	@ApiModelProperty(value = "查询类型", example = "", required = true)
+	//@ApiModelProperty(value = "查询类型", example = "", required = true)
 	private String queryType;
 	
 }

+ 2 - 7
job-admin/src/main/resources/application.properties

@@ -18,16 +18,11 @@ spring.freemarker.settings.number_format=0.##########
 
 ### mybatis
 mybatis.mapper-locations=classpath:/mybatis-mapper/*Mapper.xml
-#mybatis.type-aliases-package=com.xxl.job.admin.core.model
 
 ### xxl-job, datasource
-spring.datasource.url=jdbc:mysql://${SPRING_DATASOURCE_IP:192.168.64.15}:${SPRING_DATASOURCE_PORT:9934}/${XXL_JOB_DATABASE:xxl-job}?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false
+spring.datasource.url=jdbc:mysql://${SPRING_DATASOURCE_IP:1192.168.100.94}:${SPRING_DATASOURCE_PORT:9934}/${XXL_JOB_DATABASE:xxl-job}?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
 spring.datasource.username=${SPRING_DATASOURCE_USERNAME:root}
-spring.datasource.password=${SPRING_DATASOURCE_PASSWORD:QK5634982@#}
-
-#spring.datasource.url=jdbc:mysql://152.136.98.229:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai
-#spring.datasource.username=root
-#spring.datasource.password=QK5634982@#
+spring.datasource.password=${SPRING_DATASOURCE_PASSWORD:persagy@2020}
 
 ### datasource-pool
 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

+ 0 - 1
job-admin/src/main/resources/bootstrap.yml

@@ -6,7 +6,6 @@ server:
 spring:
   application:
     name: job-admin
-
   jackson:
     parser: 
       ALLOW_COMMENTS: true

+ 1 - 1
job-executor/src/main/resources/bootstrap.yml

@@ -13,7 +13,7 @@ integrated:
     read-timeout: ${HTTP_CLIENT_READ_TIMEOUT:120000}
     connect-timeout: ${HTTP_CLIENT_CONNECT_TIMEOUT:5000}
     max-idle-time: ${HTTP_CLIENT_MAX_IDLE_TIME:600}
-    
+
 # 默认日志级别
 logback:
   level: ${LOGBACK_LEVEL:INFO}

+ 7 - 0
pom.xml

@@ -1,6 +1,13 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0"
 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<parent>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-parent</artifactId>
+		<version>2.1.14.RELEASE</version>
+		<relativePath/>
+	</parent>
+
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>com.xuxueli</groupId>
 	<artifactId>integrated-job</artifactId>