Merge branch 'dev' of https://gitee.wang/lisb/pigx into dev

This commit is contained in:
lishangbu committed 2018-07-25 14:28:18 +08:00
commit ba80218cd9
36 files changed
+1429 -13

No files matched your search

+3 -2
View File
@@ -18,8 +18,9 @@ https://pig4cloud.com
- 完整的oAuth 流程,资源服务器控制权限
- 去除了部分对于开发不友好的中间件
### 部署说明
[部署说明](doc/deploy.md)
### 使用说明
[目录](doc/md/catalog.md)
## 协议和授权
+3
View File
@@ -0,0 +1,3 @@
[部署说明](deploy.md)
[swagger使用](swagger.md)
View File
File renamed without changes.
+58
View File
@@ -0,0 +1,58 @@
# 如何在pigx Swagger中OAuth2.0 授权
## 增加客户端
默认对所有终端进行验证码校验,但是swagger 模拟的时候不需要。
- 通过界面的形式
![](http://obq1lvsd9.bkt.clouddn.com/20180725132807.png)
- 直接操作**sys_oauth_client_details**表
```sql
INSERT INTO `pigx`.`sys_oauth_client_details` (
`authorities`,
`authorized_grant_types`,
`web_server_redirect_uri`,
`scope`,
`additional_information`,
`autoapprove`,
`resource_ids`,
`refresh_token_validity`,
`client_secret`,
`client_id`,
`access_token_validity`
)
VALUES
(
NULL,
'password,refresh_token',
NULL,
'server',
NULL,
'true',
NULL,
NULL,
'test',
'test',
NULL
);
```
## 过滤指定客户端
pigx-gateway-dev.yml
```yml
# 不校验验证码终端
ignore:
clients:
- test
```
## 填写客户端信息
![](http://obq1lvsd9.bkt.clouddn.com/20180725133119.png)
![](http://obq1lvsd9.bkt.clouddn.com/20180725133206.png)
+11 -1
View File
@@ -58,7 +58,17 @@ services:
- pigx-eureka
build:
context: ./
dockerfile: ./pigx-monitor/Dockerfile
dockerfile: ./pigx-visual/pigx-monitor/Dockerfile
restart: always
ports:
- 5001:5001
pig-daemon:
links:
- pigx-eureka
build:
context: ./
dockerfile: ./pigx-visual/pigx-daemon/Dockerfile
restart: always
ports:
- 5002:5002
+1 -1
View File
@@ -6,7 +6,7 @@ RUN mkdir -p /pigx/bin/com.pig4cloud/pigx-auth
WORKDIR /pigx/bin/com.pig4cloud/pigx-auth
EXPOSE 1025
EXPOSE 3000
ADD ./pigx-auth/target/pigx-auth.jar ./
+56
View File
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the pig4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId>
<version>${pigx.version}</version>
</parent>
<artifactId>pigx-common-job</artifactId>
<version>${pigx.version}</version>
<packaging>jar</packaging>
<name>pigx-common-job</name>
<description>pigx 定时任务</description>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- import elastic-job lite core -->
<dependency>
<groupId>com.dangdang</groupId>
<artifactId>elastic-job-lite-core</artifactId>
<version>${elastic-job-lite.version}</version>
</dependency>
<!-- import other module if need -->
<dependency>
<groupId>com.dangdang</groupId>
<artifactId>elastic-job-lite-spring</artifactId>
<version>${elastic-job-lite.version}</version>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,87 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.common.job;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;
import com.pig4cloud.pigx.common.job.jobinit.DataflowJobInitialization;
import com.pig4cloud.pigx.common.job.jobinit.ScriptJobInitialization;
import com.pig4cloud.pigx.common.job.jobinit.SimpleJobInitialization;
import com.pig4cloud.pigx.common.job.properties.ElasticJobProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author lengleng
* @date 2018/7/24
* 任务初配置入口类
*/
@Configuration
@EnableAutoConfiguration
@EnableConfigurationProperties(ElasticJobProperties.class)
public class ElasticJobAutoConfiguration {
/**
* 默认注册中心
*/
public static final String DEFAULT_REGISTRY_CENTER_NAME = "elasticJobRegistryCenter";
@Autowired
private ElasticJobProperties elasticJobProperties;
@Bean(name = DEFAULT_REGISTRY_CENTER_NAME, initMethod = "init")
@ConditionalOnMissingBean
public ZookeeperRegistryCenter elasticJobRegistryCenter() {
ElasticJobProperties.ZkConfiguration regCenterProperties = elasticJobProperties.getZookeeper();
ZookeeperConfiguration zookeeperConfiguration = new ZookeeperConfiguration(regCenterProperties.getServerLists(), regCenterProperties.getNamespace());
zookeeperConfiguration.setBaseSleepTimeMilliseconds(regCenterProperties.getBaseSleepTimeMilliseconds());
zookeeperConfiguration.setConnectionTimeoutMilliseconds(regCenterProperties.getConnectionTimeoutMilliseconds());
zookeeperConfiguration.setMaxSleepTimeMilliseconds(regCenterProperties.getMaxSleepTimeMilliseconds());
zookeeperConfiguration.setSessionTimeoutMilliseconds(regCenterProperties.getSessionTimeoutMilliseconds());
zookeeperConfiguration.setMaxRetries(regCenterProperties.getMaxRetries());
zookeeperConfiguration.setDigest(regCenterProperties.getDigest());
return new ZookeeperRegistryCenter(zookeeperConfiguration);
}
@Bean(initMethod = "init")
@ConditionalOnMissingBean
@ConditionalOnBean(ZookeeperRegistryCenter.class)
public SimpleJobInitialization simpleJobInitialization() {
return new SimpleJobInitialization(elasticJobProperties.getSimples());
}
@Bean(initMethod = "init")
@ConditionalOnMissingBean
@ConditionalOnBean(ZookeeperRegistryCenter.class)
public DataflowJobInitialization dataflowJobInitialization() {
return new DataflowJobInitialization(elasticJobProperties.getDataflows());
}
@Bean(initMethod = "init")
@ConditionalOnMissingBean
@ConditionalOnBean(ZookeeperRegistryCenter.class)
public ScriptJobInitialization scriptJobInitialization() {
return new ScriptJobInitialization(elasticJobProperties.getScripts());
}
}
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.common.job.annotation;
import com.pig4cloud.pigx.common.job.ElasticJobAutoConfiguration;
import org.springframework.context.annotation.Import;
import java.lang.annotation.*;
/**
* @author lengleng
* @date 2018/7/24
* 开启pigx job
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@Import({ElasticJobAutoConfiguration.class})
public @interface EnablePigxJob {
}
@@ -0,0 +1,285 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.common.job.jobinit;
import com.dangdang.ddframe.job.api.ElasticJob;
import com.dangdang.ddframe.job.api.JobType;
import com.dangdang.ddframe.job.api.dataflow.DataflowJob;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.dangdang.ddframe.job.config.JobCoreConfiguration;
import com.dangdang.ddframe.job.config.JobTypeConfiguration;
import com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration;
import com.dangdang.ddframe.job.executor.handler.JobProperties.JobPropertiesEnum;
import com.dangdang.ddframe.job.lite.api.listener.AbstractDistributeOnceElasticJobListener;
import com.dangdang.ddframe.job.lite.api.listener.ElasticJobListener;
import com.dangdang.ddframe.job.lite.config.LiteJobConfiguration;
import com.dangdang.ddframe.job.lite.spring.api.SpringJobScheduler;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;
import com.pig4cloud.pigx.common.job.properties.ElasticJobProperties;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.util.CollectionUtils;
import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import static com.pig4cloud.pigx.common.job.ElasticJobAutoConfiguration.DEFAULT_REGISTRY_CENTER_NAME;
/**
* @author lengleng
* @date 2018/7/24
* 任务初始化基类
*/
public abstract class AbstractJobInitialization implements ApplicationContextAware {
protected ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
/**
* 初始化任务
*
* @param jobName 任务名称
* @param jobType 任务类型
* @param configuration 配置
*/
protected void initJob(String jobName, JobType jobType, ElasticJobProperties.JobConfiguration configuration) {
//向spring容器中注册作业任务
ElasticJob elasticJob = registerElasticJob(jobName, configuration.getJobClass(), jobType);
//获取注册中心
ZookeeperRegistryCenter regCenter = getZookeeperRegistryCenter(configuration.getRegistryCenterRef());
//构建核心配置
JobCoreConfiguration jobCoreConfiguration = getJobCoreConfiguration(jobName, configuration);
//获取作业类型配置
JobTypeConfiguration jobTypeConfiguration = getJobTypeConfiguration(jobName, jobCoreConfiguration);
//获取Lite作业配置
LiteJobConfiguration liteJobConfiguration = getLiteJobConfiguration(jobTypeConfiguration, configuration);
//获取作业事件追踪的数据源配置
JobEventRdbConfiguration jobEventRdbConfiguration = getJobEventRdbConfiguration(configuration.getEventTraceRdbDataSource());
//获取作业监听器
ElasticJobListener[] elasticJobListeners = creatElasticJobListeners(configuration.getListener());
elasticJobListeners = null == elasticJobListeners ? new ElasticJobListener[0] : elasticJobListeners;
//注册作业
if (null == jobEventRdbConfiguration) {
new SpringJobScheduler(elasticJob, regCenter, liteJobConfiguration, elasticJobListeners).init();
} else {
new SpringJobScheduler(elasticJob, regCenter, liteJobConfiguration, jobEventRdbConfiguration, elasticJobListeners).init();
}
}
/**
* 获取作业类型配置
*
* @param jobName 任务名称
* @param jobCoreConfiguration 任务核心配置
* @return JobTypeConfiguration
*/
public abstract JobTypeConfiguration getJobTypeConfiguration(String jobName, JobCoreConfiguration jobCoreConfiguration);
/**
* 获取作业任务实例
*
* @param jobName 任务名称
* @param jobType 任务类型
* @param strClass 任务类全路径
* @return ElasticJob
*/
private ElasticJob registerElasticJob(String jobName, String strClass, JobType jobType) {
switch (jobType) {
case SIMPLE:
return registerBean(jobName, strClass, SimpleJob.class);
case DATAFLOW:
return registerBean(jobName, strClass, DataflowJob.class);
default:
return null;
}
}
/**
* 获取注册中心
*
* @param registryCenterRef 注册中心引用
* @return ZookeeperRegistryCenter
*/
private ZookeeperRegistryCenter getZookeeperRegistryCenter(String registryCenterRef) {
if (StringUtils.isBlank(registryCenterRef)) {
registryCenterRef = DEFAULT_REGISTRY_CENTER_NAME;
}
if (!applicationContext.containsBean(registryCenterRef)) {
throw new RuntimeException("not exist ZookeeperRegistryCenter [" + registryCenterRef + "] !");
}
return applicationContext.getBean(registryCenterRef, ZookeeperRegistryCenter.class);
}
/**
* 获取作业事件追踪的数据源配置
*
* @param eventTraceRdbDataSource 作业事件追踪的数据源Bean引用
* @return JobEventRdbConfiguration
*/
private JobEventRdbConfiguration getJobEventRdbConfiguration(String eventTraceRdbDataSource) {
if (StringUtils.isBlank(eventTraceRdbDataSource)) {
return null;
}
if (!applicationContext.containsBean(eventTraceRdbDataSource)) {
throw new RuntimeException("not exist datasource [" + eventTraceRdbDataSource + "] !");
}
DataSource dataSource = (DataSource) applicationContext.getBean(eventTraceRdbDataSource);
return new JobEventRdbConfiguration(dataSource);
}
/**
* 构建Lite作业
*
* @param jobTypeConfiguration 任务类型
* @param jobConfiguration 任务配置
* @return LiteJobConfiguration
*/
private LiteJobConfiguration getLiteJobConfiguration(JobTypeConfiguration jobTypeConfiguration, ElasticJobProperties.JobConfiguration jobConfiguration) {
//构建Lite作业
return LiteJobConfiguration.newBuilder(Objects.requireNonNull(jobTypeConfiguration))
.monitorExecution(jobConfiguration.isMonitorExecution())
.monitorPort(jobConfiguration.getMonitorPort())
.maxTimeDiffSeconds(jobConfiguration.getMaxTimeDiffSeconds())
.jobShardingStrategyClass(jobConfiguration.getJobShardingStrategyClass())
.reconcileIntervalMinutes(jobConfiguration.getReconcileIntervalMinutes())
.disabled(jobConfiguration.isDisabled())
.overwrite(jobConfiguration.isOverwrite()).build();
}
/**
* 构建任务核心配置
*
* @param jobName 任务执行名称
* @param jobConfiguration 任务配置
* @return JobCoreConfiguration
*/
protected JobCoreConfiguration getJobCoreConfiguration(String jobName, ElasticJobProperties.JobConfiguration jobConfiguration) {
JobCoreConfiguration.Builder builder = JobCoreConfiguration.newBuilder(jobName, jobConfiguration.getCron(), jobConfiguration.getShardingTotalCount())
.shardingItemParameters(jobConfiguration.getShardingItemParameters())
.jobParameter(jobConfiguration.getJobParameter())
.failover(jobConfiguration.isFailover())
.misfire(jobConfiguration.isMisfire())
.description(jobConfiguration.getDescription());
if (StringUtils.isNotBlank(jobConfiguration.getJobExceptionHandler())) {
builder.jobProperties(JobPropertiesEnum.JOB_EXCEPTION_HANDLER.getKey(), jobConfiguration.getJobExceptionHandler());
}
if (StringUtils.isNotBlank(jobConfiguration.getExecutorServiceHandler())) {
builder.jobProperties(JobPropertiesEnum.EXECUTOR_SERVICE_HANDLER.getKey(), jobConfiguration.getExecutorServiceHandler());
}
return builder.build();
}
/**
* 获取监听器
*
* @param listener 监听器配置
* @return ElasticJobListener[]
*/
private ElasticJobListener[] creatElasticJobListeners(ElasticJobProperties.JobConfiguration.Listener listener) {
if (null == listener) {
return null;
}
List<ElasticJobListener> elasticJobListeners = new ArrayList<>(2);
//注册每台作业节点均执行的监听
ElasticJobListener elasticJobListener = registerBean(listener.getListenerClass(), listener.getListenerClass(), ElasticJobListener.class);
if (null != elasticJobListener) {
elasticJobListeners.add(elasticJobListener);
}
//注册分布式监听者
AbstractDistributeOnceElasticJobListener distributedListener = registerBean(listener.getDistributedListenerClass(), listener.getDistributedListenerClass(),
AbstractDistributeOnceElasticJobListener.class, listener.getStartedTimeoutMilliseconds(), listener.getCompletedTimeoutMilliseconds());
if (null != distributedListener) {
elasticJobListeners.add(distributedListener);
}
if (CollectionUtils.isEmpty(elasticJobListeners)) {
return null;
}
//集合转数组
ElasticJobListener[] elasticJobListenerArray = new ElasticJobListener[elasticJobListeners.size()];
for (int i = 0; i < elasticJobListeners.size(); i++) {
elasticJobListenerArray[i] = elasticJobListeners.get(i);
}
return elasticJobListenerArray;
}
/**
* 向spring容器中注册bean
*
* @param beanName bean名字
* @param strClass 类全路径
* @param tClass 类类型
* @param constructorArgValue 构造函数参数
* @param <T> 泛型
* @return T
*/
protected <T> T registerBean(String beanName, String strClass, Class<T> tClass, Object... constructorArgValue) {
//判断是否配置了监听者
if (StringUtils.isBlank(strClass)) {
return null;
}
if (StringUtils.isBlank(beanName)) {
beanName = strClass;
}
//判断监听者是否已经在spring容器中存在
if (applicationContext.containsBean(beanName)) {
return applicationContext.getBean(beanName, tClass);
}
//不存在则创建并注册到Spring容器中
BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.rootBeanDefinition(strClass);
beanDefinitionBuilder.setScope(BeanDefinition.SCOPE_PROTOTYPE);
//设置参数
for (Object argValue : constructorArgValue) {
beanDefinitionBuilder.addConstructorArgValue(argValue);
}
getDefaultListableBeanFactory().registerBeanDefinition(beanName, beanDefinitionBuilder.getBeanDefinition());
return applicationContext.getBean(beanName, tClass);
}
/**
* 获取beanFactory
*
* @return DefaultListableBeanFactory
*/
private DefaultListableBeanFactory getDefaultListableBeanFactory() {
return (DefaultListableBeanFactory) ((ConfigurableApplicationContext) applicationContext).getBeanFactory();
}
}
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.common.job.jobinit;
import com.dangdang.ddframe.job.config.JobCoreConfiguration;
import com.dangdang.ddframe.job.config.JobTypeConfiguration;
import com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration;
import com.pig4cloud.pigx.common.job.properties.ElasticJobProperties;
import java.util.Map;
/**
* @author lengleng
* @date 2018/7/24
* 流式任务初始
*/
public class DataflowJobInitialization extends AbstractJobInitialization {
private Map<String, ElasticJobProperties.DataflowConfiguration> dataflowConfigurationMap;
public DataflowJobInitialization(final Map<String, ElasticJobProperties.DataflowConfiguration> dataflowConfigurationMap) {
this.dataflowConfigurationMap = dataflowConfigurationMap;
}
public void init() {
for (String jobName : dataflowConfigurationMap.keySet()) {
ElasticJobProperties.DataflowConfiguration configuration = dataflowConfigurationMap.get(jobName);
initJob(jobName, configuration.getJobType(), configuration);
}
}
@Override
public JobTypeConfiguration getJobTypeConfiguration(String jobName, JobCoreConfiguration jobCoreConfiguration) {
ElasticJobProperties.DataflowConfiguration configuration = dataflowConfigurationMap.get(jobName);
return new DataflowJobConfiguration(jobCoreConfiguration, configuration.getJobClass(), configuration.isStreamingProcess());
}
}
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.common.job.jobinit;
import com.dangdang.ddframe.job.config.JobCoreConfiguration;
import com.dangdang.ddframe.job.config.JobTypeConfiguration;
import com.dangdang.ddframe.job.config.script.ScriptJobConfiguration;
import com.pig4cloud.pigx.common.job.properties.ElasticJobProperties;
import java.util.Map;
/**
* @author lengleng
* @date 2018/7/24
* 脚本任务初始
*/
public class ScriptJobInitialization extends AbstractJobInitialization {
private Map<String, ElasticJobProperties.ScriptConfiguration> scriptConfigurationMap;
public ScriptJobInitialization(final Map<String, ElasticJobProperties.ScriptConfiguration> scriptConfigurationMap) {
this.scriptConfigurationMap = scriptConfigurationMap;
}
public void init() {
for (String jobName : scriptConfigurationMap.keySet()) {
ElasticJobProperties.ScriptConfiguration configuration = scriptConfigurationMap.get(jobName);
initJob(jobName, configuration.getJobType(), configuration);
}
}
@Override
public JobTypeConfiguration getJobTypeConfiguration(String jobName, JobCoreConfiguration jobCoreConfiguration) {
ElasticJobProperties.ScriptConfiguration configuration = scriptConfigurationMap.get(jobName);
return new ScriptJobConfiguration(jobCoreConfiguration, configuration.getScriptCommandLine());
}
}
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.common.job.jobinit;
import com.dangdang.ddframe.job.config.JobCoreConfiguration;
import com.dangdang.ddframe.job.config.JobTypeConfiguration;
import com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration;
import com.pig4cloud.pigx.common.job.properties.ElasticJobProperties;
import java.util.Map;
/**
* @author lengleng
* @date 2018/7/24
* 简单任务初始
*/
public class SimpleJobInitialization extends AbstractJobInitialization {
private Map<String, ElasticJobProperties.SimpleConfiguration> simpleConfigurationMap;
public SimpleJobInitialization(final Map<String, ElasticJobProperties.SimpleConfiguration> simpleConfigurationMap) {
this.simpleConfigurationMap = simpleConfigurationMap;
}
public void init() {
for (String jobName : simpleConfigurationMap.keySet()) {
ElasticJobProperties.SimpleConfiguration configuration = simpleConfigurationMap.get(jobName);
initJob(jobName, configuration.getJobType(), configuration);
}
}
@Override
public JobTypeConfiguration getJobTypeConfiguration(String jobName, JobCoreConfiguration jobCoreConfiguration) {
ElasticJobProperties.SimpleConfiguration configuration = simpleConfigurationMap.get(jobName);
return new SimpleJobConfiguration(jobCoreConfiguration, configuration.getJobClass());
}
}
@@ -0,0 +1,293 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.common.job.properties;
import com.dangdang.ddframe.job.api.JobType;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.LinkedHashMap;
import java.util.Map;
import static com.pig4cloud.pigx.common.job.ElasticJobAutoConfiguration.DEFAULT_REGISTRY_CENTER_NAME;
/**
* @author lengleng
* @date 2018/7/24
* 任务配置类
*/
@Getter
@Setter
@ConfigurationProperties(prefix = "spring.elasticjob")
public class ElasticJobProperties {
/**
* 注册中心
*/
private ZkConfiguration zookeeper;
/**
* 简单作业配置
*/
private Map<String, SimpleConfiguration> simples = new LinkedHashMap<>();
/**
* 流式作业配置
*/
private Map<String, DataflowConfiguration> dataflows = new LinkedHashMap<>();
/**
* 脚本作业配置
*/
private Map<String, ScriptConfiguration> scripts = new LinkedHashMap<>();
@Getter
@Setter
public static class ZkConfiguration {
/**
* 连接Zookeeper服务器的列表
* 包括IP地址和端口号
* 多个地址用逗号分隔
* 如: host1:2181,host2:2181
*/
private String serverLists;
/**
* Zookeeper的命名空间
*/
private String namespace;
/**
* 等待重试的间隔时间的初始值
* 单位:毫秒
*/
private int baseSleepTimeMilliseconds = 1000;
/**
* 等待重试的间隔时间的最大值
* 单位:毫秒
*/
private int maxSleepTimeMilliseconds = 3000;
/**
* 最大重试次数
*/
private int maxRetries = 3;
/**
* 连接超时时间
* 单位:毫秒
*/
private int connectionTimeoutMilliseconds = 15000;
/**
* 会话超时时间
* 单位:毫秒
*/
private int sessionTimeoutMilliseconds = 60000;
/**
* 连接Zookeeper的权限令牌
* 缺省为不需要权限验
*/
private String digest;
}
@Getter
@Setter
public static class SimpleConfiguration extends JobConfiguration {
/**
* 作业类型
*/
private final JobType jobType = JobType.SIMPLE;
}
@Getter
@Setter
public static class DataflowConfiguration extends JobConfiguration {
/**
* 作业类型
*/
private final JobType jobType = JobType.DATAFLOW;
/**
* 是否流式处理数据
* 如果流式处理数据, 则fetchData不返回空结果将持续执行作业
* 如果非流式处理数据, 则处理数据完成后作业结束
*/
private boolean streamingProcess = false;
}
@Getter
@Setter
public static class ScriptConfiguration extends JobConfiguration {
/**
* 作业类型
*/
private final JobType jobType = JobType.SCRIPT;
/**
* 脚本型作业执行命令行
*/
private String scriptCommandLine;
}
@Getter
@Setter
public static class JobConfiguration {
/**
* 作业实现类,需实现ElasticJob接口
*/
private String jobClass;
/**
* 注册中心Bean的引用,需引用reg:zookeeper的声明
*/
private String registryCenterRef = DEFAULT_REGISTRY_CENTER_NAME;
/**
* cron表达式,用于控制作业触发时间
*/
private String cron;
/**
* 作业分片总数
*/
private int shardingTotalCount = 1;
/**
* 分片序列号和参数用等号分隔,多个键值对用逗号分隔
* 分片序列号从0开始,不可大于或等于作业分片总数
* 如:0=a,1=b,2=c
*/
private String shardingItemParameters = "0=A";
/**
* 作业实例主键,同IP可运行实例主键不同, 但名称相同的多个作业实例
*/
private String jobInstanceId;
/**
* 作业自定义参数
* 作业自定义参数,可通过传递该参数为作业调度的业务方法传参,用于实现带参数的作业
* 例:每次获取的数据量、作业实例从数据库读取的主键等
*/
private String jobParameter;
/**
* 监控作业运行时状态
* 每次作业执行时间和间隔时间均非常短的情况,建议不监控作业运行时状态以提升效率。
* 因为是瞬时状态,所以无必要监控。请用户自行增加数据堆积监控。并且不能保证数据重复选取,应在作业中实现幂等性。
* 每次作业执行时间和间隔时间均较长的情况,建议监控作业运行时状态,可保证数据不会重复选取。
*/
private boolean monitorExecution = true;
/**
* 作业监控端口
* 建议配置作业监控端口, 方便开发者dump作业信息。
* 使用方法: echo “dump” | nc 127.0.0.1 9888
*/
private int monitorPort = -1;
/**
* 最大允许的本机与注册中心的时间误差秒数
* 如果时间误差超过配置秒数则作业启动时将抛异常
* 配置为-1表示不校验时间误差
*/
private int maxTimeDiffSeconds = -1;
/**
* 是否开启失效转移
*/
private boolean failover = false;
/**
* 是否开启错过任务重新执行
*/
private boolean misfire = true;
/**
* 作业分片策略实现类全路径
* 默认使用平均分配策略
* 详情参见:作业分片策略http://elasticjob.io/docs/elastic-job-lite/02-guide/job-sharding-strategy
*/
private String jobShardingStrategyClass;
/**
* 作业描述信息
*/
private String description;
/**
* 作业是否禁止启动
* 可用于部署作业时,先禁止启动,部署结束后统一启动
*/
private boolean disabled = false;
/**
* 本地配置是否可覆盖注册中心配置
* 如果可覆盖,每次启动作业都以本地配置为准
*/
private boolean overwrite = true;
/**
* 扩展异常处理类
*/
private String jobExceptionHandler;
/**
* 扩展作业处理线程池类
*/
private String executorServiceHandler;
/**
* 修复作业服务器不一致状态服务调度间隔时间,配置为小于1的任意值表示不执行修复
* 单位:分钟
*/
private int reconcileIntervalMinutes = 10;
/**
* 作业事件追踪的数据源Bean引用
*/
private String eventTraceRdbDataSource;
/**
* 监听器
*/
private Listener listener;
@Getter
@Setter
public static class Listener {
/**
* 每台作业节点均执行的监听
* 若作业处理作业服务器的文件,处理完成后删除文件,可考虑使用每个节点均执行清理任务。
* 此类型任务实现简单,且无需考虑全局分布式任务是否完成,请尽量使用此类型监听器。
*
* <p>注意:类必须继承com.dangdang.ddframe.job.lite.api.listener.ElasticJobListener</p>
*/
String listenerClass;
/**
* 分布式场景中仅单一节点执行的监听
* 若作业处理数据库数据,处理完成后只需一个节点完成数据清理任务即可。
* 此类型任务处理复杂,需同步分布式环境下作业的状态同步,提供了超时设置来避免作业不同步导致的死锁,请谨慎使用。
*
* <p>注意:类必须继承com.dangdang.ddframe.job.lite.api.listener.AbstractDistributeOnceElasticJobListener</p>
*/
String distributedListenerClass;
/**
* 最后一个作业执行前的执行方法的超时时间
* 单位:毫秒
*/
Long startedTimeoutMilliseconds = Long.MAX_VALUE;
/**
* 最后一个作业执行后的执行方法的超时时间
* 单位:毫秒
*/
Long completedTimeoutMilliseconds = Long.MAX_VALUE;
}
}
}
+1 -1
View File
@@ -30,7 +30,7 @@
<artifactId>pigx-common-swagger</artifactId>
<version>${pigx.version}</version>
<packaging>jar</packaging>
<name>pigx-common-log</name>
<name>pigx-common-swagger</name>
<description>pigx 接口文档</description>
+1
View File
@@ -35,6 +35,7 @@
<modules>
<module>pigx-common-core</module>
<module>pigx-common-job</module>
<module>pigx-common-log</module>
<module>pigx-common-security</module>
<module>pigx-common-swagger</module>
+1 -1
View File
@@ -6,7 +6,7 @@ RUN mkdir -p /pigx/bin/com.pig4cloud/pigx-config
WORKDIR /pigx/bin/com.pig4cloud/pigx-config
EXPOSE 1025
EXPOSE 4001
ADD ./pigx-config/target/pigx-config.jar ./
@@ -0,0 +1,36 @@
spring:
# 保存定时任务的数据源
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
url: jdbc:mysql://127.0.0.1:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
elasticjob:
# 分布式任务协调依赖zookeeper
zookeeper:
server-lists: 127.0.0.1:2181
namespace: pigx-daemon
# 普通任务
simples:
spring-simple-job:
job-class: com.pig4cloud.pigx.daemon.job.PigxSimpleJob
cron: 0/2 * * * * ?
sharding-total-count: 3
sharding-item-parameters: 0=service1,1=service2,2=service3
eventTraceRdbDataSource: 'dataSource'
listener:
listener-class: com.pig4cloud.pigx.daemon.listener.PigxElasticJobListener
# 简单任务
dataflows:
spring-dataflow-job:
job-class: com.pig4cloud.pigx.daemon.job.PigxDataflowJob
cron: 0/2 * * * * ?
sharding-total-count: 3
sharding-item-parameters: 0=service1,1=service2,2=service3
streaming-process: true
eventTraceRdbDataSource: 'dataSource'
listener:
distributed-listener-class: com.pig4cloud.pigx.daemon.listener.PigxDistributeElasticJobListener
started-timeout-milliseconds: 5000
completed-timeout-milliseconds: 10000
+5
View File
@@ -46,6 +46,11 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
</dependency>
<!--配置中心客户端-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<!--web 模块-->
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -32,7 +32,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests()
.antMatchers("actuator/**").permitAll()
.antMatchers("/actuator/**").permitAll()
.anyRequest()
.authenticated().and().httpBasic();
}
@@ -8,6 +8,12 @@ spring:
password: pig
application:
name: pigx-eureka
boot:
admin:
client:
url: http://localhost:5001
instance:
name: PIGX-EUREKA
# docker-compose部署时候 hostname 换成pigx-eureka
# 类似的 redis 使用pigx-redis ,gateway 换成 pigx-gateway
+1 -1
View File
@@ -6,7 +6,7 @@ RUN mkdir -p /pigx/bin/com.pig4cloud/pigx-gateway
WORKDIR /pigx/bin/com.pig4cloud/pigx-gateway
EXPOSE 1025
EXPOSE 9999
ADD ./pigx-gateway/target/pigx-gateway.jar ./
+13
View File
@@ -0,0 +1,13 @@
FROM anapsix/alpine-java:8_server-jre_unlimited
MAINTAINER wangiegie@gmail.com
RUN mkdir -p /pigx/bin/com.pig4cloud/pigx-daemon
WORKDIR /pigx/bin/com.pig4cloud/pigx-daemon
EXPOSE 5002
ADD ./pigx-visual/pigx-daemon/target/pigx-daemon.jar ./
CMD java -Djava.security.egd=file:/dev/./urandom -jar pigx-daemon.jar
+98
View File
@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the pig4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
-->
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId>
<version>${pigx.version}</version>
</parent>
<artifactId>pigx-daemon</artifactId>
<version>${pigx.version}</version>
<packaging>jar</packaging>
<name>pigx-daemon</name>
<description>后台跑批定时任务模块</description>
<dependencies>
<!--配置中心客户端-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<!--跑批任务-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-job</artifactId>
<version>${pigx.version}</version>
</dependency>
<!--数据库-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!--ZK 依赖-->
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>${curator.version}</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<version>${curator.version}</version>
</dependency>
<!--web 模块-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!--排除tomcat依赖-->
<exclusion>
<artifactId>spring-boot-starter-tomcat</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
<!--undertow容器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.daemon;
import com.pig4cloud.pigx.common.job.annotation.EnablePigxJob;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author lengleng
* @date 2018/7/24
* 分布式任务调度模块
*/
@EnablePigxJob
@SpringBootApplication
public class PigxDaemonApplication {
public static void main(String[] args) {
SpringApplication.run(PigxDaemonApplication.class, args);
}
}
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.daemon.job;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.dataflow.DataflowJob;
import java.util.List;
/**
* @author lengleng
* @date 2018/2/8
*/
public class PigxDataflowJob implements DataflowJob<Integer> {
@Override
public List<Integer> fetchData(ShardingContext shardingContext) {
return null;
}
@Override
public void processData(ShardingContext shardingContext, List<Integer> list) {
}
}
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.daemon.job;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
/**
* @author lengleng
* @date 2018/2/7
* 测试Job
*/
@Slf4j
public class PigxSimpleJob implements SimpleJob {
/**
* 业务执行逻辑
*
* @param shardingContext 分片信息
*/
@Override
public void execute(ShardingContext shardingContext) {
log.info("shardingContext:{}", shardingContext);
}
}
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.daemon.listener;
import com.dangdang.ddframe.job.executor.ShardingContexts;
import com.dangdang.ddframe.job.lite.api.listener.AbstractDistributeOnceElasticJobListener;
/**
* @author lengleng
* @date 2018/7/24
*/
public class PigxDistributeElasticJobListener extends AbstractDistributeOnceElasticJobListener {
public PigxDistributeElasticJobListener(long startedTimeoutMilliseconds, long completedTimeoutMilliseconds) {
super(startedTimeoutMilliseconds, completedTimeoutMilliseconds);
}
@Override
public void doBeforeJobExecutedAtLastStarted(ShardingContexts shardingContexts) {
System.out.println(shardingContexts.getJobName() + " | MyDistributeElasticJobListener doBeforeJobExecutedAtLastStarted...");
}
@Override
public void doAfterJobExecutedAtLastCompleted(ShardingContexts shardingContexts) {
System.out.println(shardingContexts.getJobName() + " | MyDistributeElasticJobListener doAfterJobExecutedAtLastCompleted...");
}
}
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.daemon.listener;
import com.dangdang.ddframe.job.executor.ShardingContexts;
import com.dangdang.ddframe.job.lite.api.listener.ElasticJobListener;
/**
* @author lengleng
* @date 2018/7/24
* 任务监听器
*/
public class PigxElasticJobListener implements ElasticJobListener {
@Override
public void beforeJobExecuted(ShardingContexts shardingContexts) {
System.out.println(shardingContexts.getJobName() + " | MyElasticJobListener beforeJobExecuted");
}
@Override
public void afterJobExecuted(ShardingContexts shardingContexts) {
System.out.println(shardingContexts.getJobName() + " | MyElasticJobListener afterJobExecuted");
}
}
@@ -0,0 +1,23 @@
server:
port: 5002
spring:
application:
name: pigx-daemon
#配置中心
cloud:
config:
fail-fast: true
name: ${spring.application.name}
profile: dev
discovery:
enabled: true
service-id: pigx-config
# 注册中心配置
eureka:
instance:
prefer-ip-address: true
client:
service-url:
defaultZone: http://pig:pig@localhost:1025/eureka/
@@ -6,8 +6,8 @@ RUN mkdir -p /pigx/bin/com.pig4cloud/pigx-monitor
WORKDIR /pigx/bin/com.pig4cloud/pigx-monitor
EXPOSE 1025
EXPOSE 5001
ADD ./pigx-monitor/target/pigx-monitor.jar ./
ADD ./pigx-visual/pigx-monitor/target/pigx-monitor.jar ./
CMD java -Djava.security.egd=file:/dev/./urandom -jar pigx-monitor.jar
@@ -23,7 +23,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<artifactId>pigx-visual</artifactId>
<version>${pigx.version}</version>
</parent>
@@ -46,6 +46,11 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<!--配置中心客户端-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<!--web 模块-->
<dependency>
<groupId>org.springframework.boot</groupId>
+40
View File
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the pig4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<version>${pigx.version}</version>
</parent>
<artifactId>pigx-visual</artifactId>
<version>${pigx.version}</version>
<name>pigx-visual</name>
<description>pigx 图形化功能模块</description>
<packaging>pom</packaging>
<modules>
<module>pigx-daemon</module>
<module>pigx-monitor</module>
</modules>
</project>
+5 -2
View File
@@ -37,7 +37,7 @@
</parent>
<properties>
<pigx.version>1.2.4</pigx.version>
<pigx.version>1.3.0</pigx.version>
<spring-boot.version>2.0.3.RELEASE</spring-boot.version>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -50,6 +50,9 @@
<fastjson.version>1.2.47</fastjson.version>
<kaptcha.version>0.0.9</kaptcha.version>
<swagger.version>2.9.2</swagger.version>
<elastic-job.version>2.0.0</elastic-job.version>
<curator.version>2.10.0</curator.version>
<elastic-job-lite.version>2.1.5</elastic-job-lite.version>
<security.oauth.version>2.3.3.RELEASE</security.oauth.version>
</properties>
@@ -103,7 +106,7 @@
<module>pigx-auth</module>
<module>pigx-upms</module>
<module>pigx-common</module>
<module>pigx-monitor</module>
<module>pigx-visual</module>
</modules>
<dependencyManagement>