hs-extend/hs-monitor-admin/src/main/java/com/sunsail/monitor/admin/MonitorAdminApplication.java
New file @@ -0,0 +1,19 @@ package com.sunsail.monitor.admin; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * Admin 监控启动程序 * * @author Lion Li */ @SpringBootApplication public class MonitorAdminApplication { public static void main(String[] args) { SpringApplication.run(MonitorAdminApplication.class, args); System.out.println("Admin 监控启动成功"); } } hs-extend/hs-monitor-admin/src/main/java/com/sunsail/monitor/admin/config/AdminServerConfig.java
New file @@ -0,0 +1,31 @@ package com.sunsail.monitor.admin.config; import de.codecentric.boot.admin.server.config.EnableAdminServer; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration; import org.springframework.boot.task.TaskExecutorBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import java.util.concurrent.Executor; /** * springboot-admin server配置类 * * @author Lion Li */ @Configuration @EnableAdminServer public class AdminServerConfig { @Lazy @Bean(name = TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME) @ConditionalOnMissingBean(Executor.class) public ThreadPoolTaskExecutor applicationTaskExecutor(TaskExecutorBuilder builder) { return builder.build(); } } hs-extend/hs-monitor-admin/src/main/java/com/sunsail/monitor/admin/config/SecurityConfig.java
New file @@ -0,0 +1,56 @@ package com.sunsail.monitor.admin.config; import de.codecentric.boot.admin.server.config.AdminServerProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler; import org.springframework.security.web.util.matcher.AntPathRequestMatcher; /** * admin 监控 安全配置 * * @author Lion Li */ @EnableWebSecurity @Configuration public class SecurityConfig { private final String adminContextPath; public SecurityConfig(AdminServerProperties adminServerProperties) { this.adminContextPath = adminServerProperties.getContextPath(); } @Bean public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler(); successHandler.setTargetUrlParameter("redirectTo"); successHandler.setDefaultTargetUrl(adminContextPath + "/"); return httpSecurity .headers((header) -> header.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable)) .authorizeHttpRequests((authorize) -> authorize.requestMatchers( new AntPathRequestMatcher(adminContextPath + "/assets/**"), new AntPathRequestMatcher(adminContextPath + "/login"), new AntPathRequestMatcher("/actuator"), new AntPathRequestMatcher("/actuator/**") ).permitAll() .anyRequest().authenticated()) .formLogin((formLogin) -> formLogin.loginPage(adminContextPath + "/login").successHandler(successHandler)) .logout((logout) -> logout.logoutUrl(adminContextPath + "/logout")) .httpBasic(Customizer.withDefaults()) .csrf(AbstractHttpConfigurer::disable) .build(); } } hs-extend/hs-monitor-admin/src/main/java/com/sunsail/monitor/admin/notifier/CustomNotifier.java
New file @@ -0,0 +1,40 @@ package com.sunsail.monitor.admin.notifier; import de.codecentric.boot.admin.server.domain.entities.Instance; import de.codecentric.boot.admin.server.domain.entities.InstanceRepository; import de.codecentric.boot.admin.server.domain.events.InstanceEvent; import de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent; import de.codecentric.boot.admin.server.notify.AbstractEventNotifier; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import reactor.core.publisher.Mono; /** * 自定义事件通知处理 * * @author Lion Li */ @Slf4j @Component public class CustomNotifier extends AbstractEventNotifier { protected CustomNotifier(InstanceRepository repository) { super(repository); } @Override @SuppressWarnings("all") protected Mono<Void> doNotify(InstanceEvent event, Instance instance) { return Mono.fromRunnable(() -> { // 实例状态改变事件 if (event instanceof InstanceStatusChangedEvent) { String registName = instance.getRegistration().getName(); String instanceId = event.getInstance().getValue(); String status = ((InstanceStatusChangedEvent) event).getStatusInfo().getStatus(); log.info("Instance Status Change: [{}],[{}],[{}]", registName, instanceId, status); } }); } } hs-extend/hs-monitor-admin/src/main/resources/application.yml
New file @@ -0,0 +1,45 @@ server: port: 9090 spring: application: name: ruoyi-monitor-admin profiles: active: @profiles.active@ logging: config: classpath:logback-plus.xml --- # 监控中心服务端配置 spring: security: user: name: ruoyi password: 123456 boot: admin: ui: title: RuoYi-Vue-Plus服务监控中心 context-path: /admin --- # Actuator 监控端点的配置项 management: endpoints: web: exposure: include: '*' endpoint: health: show-details: ALWAYS logfile: external-file: ./logs/ruoyi-monitor-admin.log --- # 监控配置 spring.boot.admin.client: # 增加客户端开关 enabled: true # 设置 Spring Boot Admin Server 地址 url: http://localhost:9090/admin instance: service-host-type: IP username: ruoyi password: 123456 hs-extend/hs-monitor-admin/src/main/resources/banner.txt
New file @@ -0,0 +1,8 @@ Application Version: ${revision} Spring Boot Version: ${spring-boot.version} __ __ _ _ _ _ | \/ | (_) | /\ | | (_) | \ / | ___ _ __ _| |_ ___ _ __ ______ / \ __| |_ __ ___ _ _ __ | |\/| |/ _ \| '_ \| | __/ _ \| '__|______/ /\ \ / _` | '_ ` _ \| | '_ \ | | | | (_) | | | | | || (_) | | / ____ \ (_| | | | | | | | | | | |_| |_|\___/|_| |_|_|\__\___/|_| /_/ \_\__,_|_| |_| |_|_|_| |_| hs-extend/hs-monitor-admin/src/main/resources/logback-plus.xml
New file @@ -0,0 +1,34 @@ <?xml version="1.0" encoding="UTF-8"?> <configuration debug="false" scan="true" scanPeriod="1 seconds"> <contextName>logback</contextName> <property name="log.path" value="./logs/ruoyi-monitor-admin"/> <property name="console.log.pattern" value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/> <property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"/> <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>${console.log.pattern}</pattern> <charset>utf-8</charset> </encoder> </appender> <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.path}.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${log.path}.%d{yyyy-MM-dd}.log</fileNamePattern> <!-- 日志最大的历史 60天 --> <maxHistory>60</maxHistory> </rollingPolicy> <encoder> <pattern>${log.pattern}</pattern> </encoder> </appender> <root level="info"> <appender-ref ref="console"/> <appender-ref ref="file"/> </root> </configuration> hs-extend/hs-powerjob-server/.flattened-pom.xml
New file @@ -0,0 +1,61 @@ <?xml version="1.0" encoding="UTF-8"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.sunsail</groupId> <artifactId>hs-extend</artifactId> <version>5.1.2</version> </parent> <groupId>com.sunsail</groupId> <artifactId>hs-powerjob-server</artifactId> <version>5.1.2</version> <properties> <spring-boot-admin.version>2.7.11</spring-boot-admin.version> <spring-boot.version>2.7.18</spring-boot.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>${spring-boot.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>tech.powerjob</groupId> <artifactId>powerjob-server-starter</artifactId> <version>${powerjob.version}</version> </dependency> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-starter-client</artifactId> <version>${spring-boot-admin.version}</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> </dependencies> <build> <finalName>${project.artifactId}</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>${spring-boot.version}</version> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> hs-extend/hs-powerjob-server/Dockerfile
New file @@ -0,0 +1,17 @@ #FROM findepi/graalvm:java17-native FROM openjdk:17.0.2-oraclelinux8 MAINTAINER Lion Li RUN mkdir -p /ruoyi/powerjob/logs WORKDIR /ruoyi/powerjob ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 JAVA_OPTS="-Xms512m -Xmx1024m" EXPOSE 7700 ADD ./target/ruoyi-powerjob-server.jar ./app.jar ENTRYPOINT java -Djava.security.egd=file:/dev/./urandom -jar app.jar \ -XX:+HeapDumpOnOutOfMemoryError -Xlog:gc*,:time,tags,level -XX:+UseZGC ${JAVA_OPTS} hs-extend/hs-powerjob-server/pom.xml
New file @@ -0,0 +1,68 @@ <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/maven-v4_0_0.xsd"> <parent> <groupId>com.sunsail</groupId> <artifactId>hs-extend</artifactId> <version>${revision}</version> </parent> <modelVersion>4.0.0</modelVersion> <packaging>jar</packaging> <artifactId>hs-powerjob-server</artifactId> <properties> <spring-boot.version>2.7.18</spring-boot.version> <spring-boot-admin.version>2.7.11</spring-boot-admin.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>${spring-boot.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <!-- PowerJob server--> <dependency> <groupId>tech.powerjob</groupId> <artifactId>powerjob-server-starter</artifactId> <version>${powerjob.version}</version> </dependency> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-starter-client</artifactId> <version>${spring-boot-admin.version}</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> </dependencies> <build> <finalName>${project.artifactId}</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>${spring-boot.version}</version> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> hs-extend/hs-powerjob-server/src/main/java/com/sunsail/powerjob/PowerJobServerApplication.java
New file @@ -0,0 +1,25 @@ package com.sunsail.powerjob; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.scheduling.annotation.EnableScheduling; import tech.powerjob.server.common.utils.PropertyUtils; /** * powerjob 启动程序 * * @author yhan219 */ @Slf4j @EnableScheduling @SpringBootApplication(scanBasePackages = "tech.powerjob.server") public class PowerJobServerApplication { public static void main(String[] args) { PropertyUtils.init(); SpringApplication.run(tech.powerjob.server.PowerJobServerApplication.class, args); log.info("文档地址: https://www.yuque.com/powerjob/guidence/problem"); } } hs-extend/hs-powerjob-server/src/main/resources/application-dev.properties
New file @@ -0,0 +1,50 @@ oms.env=dev ####### Database properties(Configure according to the the environment) ####### spring.datasource.core.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.core.jdbc-url=jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true spring.datasource.core.username=root spring.datasource.core.password=root spring.datasource.core.maximum-pool-size=20 spring.datasource.core.minimum-idle=5 # 监控配置 # 客户端开关 spring.boot.admin.client.enabled=true # 设置 Spring Boot Admin Server 地址 spring.boot.admin.client.url: http://localhost:9090/admin spring.boot.admin.client.instance.service-host-type=IP spring.boot.admin.client.username=ruoyi spring.boot.admin.client.password=123456 ####### MongoDB properties(Non-core configuration properties) ####### ####### delete mongodb config to disable mongodb ####### oms.mongodb.enable=false #spring.data.mongodb.uri=mongodb+srv://zqq:No1Bug2Please3!@cluster0.wie54.gcp.mongodb.net/powerjob_daily?retryWrites=true&w=majority ####### Email properties(Non-core configuration properties) ####### ####### Delete the following code to disable the mail ####### #spring.mail.host=smtp.163.com #spring.mail.username=zqq@163.com #spring.mail.password=GOFZPNARMVKCGONV #spring.mail.properties.mail.smtp.auth=true #spring.mail.properties.mail.smtp.starttls.enable=true #spring.mail.properties.mail.smtp.starttls.required=true ####### DingTalk properties(Non-core configuration properties) ####### ####### Delete the following code to disable the DingTalk ####### #oms.alarm.ding.app-key=dingauqwkvxxnqskknfv #oms.alarm.ding.app-secret=XWrEPdAZMPgJeFtHuL0LH73LRj-74umF2_0BFcoXMfvnX0pCQvt0rpb1JOJU_HLl #oms.alarm.ding.agent-id=847044348 ####### Resource cleaning properties ####### oms.instanceinfo.retention=1 oms.container.retention.local=1 oms.container.retention.remote=-1 ####### Cache properties ####### oms.instance.metadata.cache.size=1024 ####### Threshold in precise fetching server(0~100). 100 means full detection of server, in which ####### ####### split-brain could be avoided while performance overhead would increase. ####### oms.accurate.select.server.percentage = 50 hs-extend/hs-powerjob-server/src/main/resources/application-prod.properties
New file @@ -0,0 +1,50 @@ oms.env=prod ####### Database properties(Configure according to the the environment) ####### spring.datasource.core.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.core.jdbc-url=jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true spring.datasource.core.username=root spring.datasource.core.password=root spring.datasource.core.maximum-pool-size=20 spring.datasource.core.minimum-idle=5 # 监控配置 # 客户端开关 spring.boot.admin.client.enabled=true # 设置 Spring Boot Admin Server 地址 spring.boot.admin.client.url: http://localhost:9090/admin spring.boot.admin.client.instance.service-host-type=IP spring.boot.admin.client.username=ruoyi spring.boot.admin.client.password=123456 ####### MongoDB properties(Non-core configuration properties) ####### ####### delete mongodb config to disable mongodb ####### oms.mongodb.enable=false #spring.data.mongodb.uri=mongodb+srv://zqq:No1Bug2Please3!@cluster0.wie54.gcp.mongodb.net/powerjob_daily?retryWrites=true&w=majority ####### Email properties(Non-core configuration properties) ####### ####### Delete the following code to disable the mail ####### #spring.mail.host=smtp.163.com #spring.mail.username=zqq@163.com #spring.mail.password=GOFZPNARMVKCGONV #spring.mail.properties.mail.smtp.auth=true #spring.mail.properties.mail.smtp.starttls.enable=true #spring.mail.properties.mail.smtp.starttls.required=true ####### DingTalk properties(Non-core configuration properties) ####### ####### Delete the following code to disable the DingTalk ####### #oms.alarm.ding.app-key=dingauqwkvxxnqskknfv #oms.alarm.ding.app-secret=XWrEPdAZMPgJeFtHuL0LH73LRj-74umF2_0BFcoXMfvnX0pCQvt0rpb1JOJU_HLl #oms.alarm.ding.agent-id=847044348 ####### Resource cleaning properties ####### oms.instanceinfo.retention=7 oms.container.retention.local=7 oms.container.retention.remote=-1 ####### Cache properties ####### oms.instance.metadata.cache.size=2048 ####### Threshold in precise fetching server(0~100). 100 means full detection of server, in which ####### ####### split-brain could be avoided while performance overhead would increase. ####### oms.accurate.select.server.percentage = 50 hs-extend/hs-powerjob-server/src/main/resources/application.properties
New file @@ -0,0 +1,33 @@ # Http server port server.port=7700 spring.profiles.active=@profiles.active@ spring.main.banner-mode=log spring.jpa.open-in-view=false spring.data.mongodb.repositories.type=none logging.level.org.mongodb=warn logging.level.tech.powerjob.server=warn logging.level.MONITOR_LOGGER_DB_OPERATION=warn logging.level.MONITOR_LOGGER_WORKER_HEART_BEAT=warn logging.config: classpath:logback-plus.xml # Configuration for uploading files. spring.servlet.multipart.enabled=true spring.servlet.multipart.file-size-threshold=0 spring.servlet.multipart.max-file-size=209715200 spring.servlet.multipart.max-request-size=209715200 ###### PowerJob transporter configuration ###### oms.transporter.active.protocols=AKKA,HTTP oms.transporter.main.protocol=HTTP oms.akka.port=10086 oms.http.port=10010 # Prefix for all tables. Default empty string. Config if you have needs, i.e. pj_ oms.table-prefix=pj_ # Actuator 监控端点的配置项 spring.application.name: ruoyi-powerjob-server management.endpoints.web.exposure.include=* management.endpoint.health.show-details=ALWAYS management.endpoint.logfile.external-file=./logs/ruoyi-powerjob-server.log management.health.mongo.enabled=${oms.mongodb.enable} hs-extend/hs-powerjob-server/src/main/resources/banner.txt
New file @@ -0,0 +1,11 @@ Application Version: ${revision} Spring Boot Version: ${spring-boot.version} _ _ (_) | | _ __ _____ _____ _ __ _ ___ | |__ ______ ___ ___ _ ____ _____ _ __ | '_ \ / _ \ \ /\ / / _ \ '__| |/ _ \| '_ \______/ __|/ _ \ '__\ \ / / _ \ '__| | |_) | (_) \ V V / __/ | | | (_) | |_) | \__ \ __/ | \ V / __/ | | .__/ \___/ \_/\_/ \___|_| | |\___/|_.__/ |___/\___|_| \_/ \___|_| | | _/ | |_| |__/ hs-extend/hs-powerjob-server/src/main/resources/logback-plus.xml
New file @@ -0,0 +1,34 @@ <?xml version="1.0" encoding="UTF-8"?> <configuration debug="false" scan="true" scanPeriod="1 seconds"> <contextName>logback</contextName> <property name="log.path" value="./logs/ruoyi-powerjob-server"/> <property name="console.log.pattern" value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/> <property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"/> <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>${console.log.pattern}</pattern> <charset>utf-8</charset> </encoder> </appender> <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.path}.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${log.path}.%d{yyyy-MM-dd}.log</fileNamePattern> <!-- 日志最大的历史 60天 --> <maxHistory>60</maxHistory> </rollingPolicy> <encoder> <pattern>${log.pattern}</pattern> </encoder> </appender> <root level="info"> <appender-ref ref="console"/> <appender-ref ref="file"/> </root> </configuration>