Commit 8924cb9b authored by 陈红帅's avatar 陈红帅

perf(admin.springboot):集群部署

parent d1e9ab1b
......@@ -25,6 +25,10 @@ public class XxlJobAdminApplication {
if(args == null || args.length == 0){
throw new RuntimeException("请传入zookeeper的地址");
}
if (args.length < 2){
throw new RuntimeException("请传入项目启动的端口号---第二个参数");
}
System.setProperty("server.port", args[1]);
ZookeeperClientUtil.init(args[0], "/weixt/conf");
// 创建zookeeper客户端
ZookeeperClientUtil configurationClient = new ZookeeperClientUtil();
......@@ -34,7 +38,7 @@ public class XxlJobAdminApplication {
}
private static void setSystemPropertie(ZookeeperClientUtil configurationClient, String key){
String value = configurationClient.getData(configurationClient.mainPath + "/" + key);
String value = configurationClient.getData(ZookeeperClientUtil.mainPath + "/" + key);
if(StringUtils.isEmpty(value)){
throw new RuntimeException("zookeeper中没有该属性的值:" + key);
}
......
### web
server.port=8181
#server.port=8181
server.context-path=/xxl-job-admin
### resources
......
......@@ -4,6 +4,7 @@ import com.alibaba.dubbo.common.utils.ConfigUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import java.util.Arrays;
import java.util.Properties;
/**
......@@ -14,9 +15,30 @@ public class XxlJobExecutorApplication {
public static void main(String[] args) {
initZookeeperAddres(args);
setAdminAddres(args);
SpringApplication.run(XxlJobExecutorApplication.class, args);
}
private static void setAdminAddres(String[] args){
// xxl.job.admin.addresses=http://127.0.0.1:8181/xxl-job-admin
String adminAddres = getAdminAddres(args);
System.out.println(adminAddres);
System.setProperty("xxl.job.admin.addresses", adminAddres);
}
private static String getAdminAddres(String[] args){
if (args.length < 2){
throw new RuntimeException("请输入调度中心的端口,如果是多个(集群)使用逗号(,)进行间隔");
}
String[] portArr = args[1].split(",");
StringBuilder resultBuilder = new StringBuilder();
for (String port : portArr) {
resultBuilder.append("http://127.0.0.1:" + port + "/xxl-job-admin,");
}
String resultStr = resultBuilder.deleteCharAt(resultBuilder.length() - 1).toString();
return resultStr;
}
/**
* 促使化dubbo注册中心的地址
* @param args
......
......@@ -6,7 +6,7 @@ logging.config=classpath:logback.xml
### xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
xxl.job.admin.addresses=http://127.0.0.1:8181/xxl-job-admin
#xxl.job.admin.addresses=http://127.0.0.1:8181/xxl-job-admin
### xxl-job executor address
xxl.job.executor.appname=com-spacetech-service-xxl-job-springboot
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment