pm2java的后端实现
parent
e70012bf53
commit
6d3f46f6f4
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
@ -0,0 +1,54 @@
|
||||
2023-10-30 15:40:52,633 ERROR (DirectJDKLog.java:175)- Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
|
||||
java.lang.NullPointerException: null
|
||||
at com.leaper.pm2java.service.impl.Pm2JavaServiceImpl.stop(Pm2JavaServiceImpl.java:275)
|
||||
at com.leaper.pm2java.controller.AppCenterController.stop(AppCenterController.java:31)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
|
||||
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
|
||||
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
|
||||
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
|
||||
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1071)
|
||||
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:964)
|
||||
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
|
||||
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
|
||||
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
|
||||
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
|
||||
at javax.servlet.http.HttpServlet.service(HttpServlet.java:779)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
|
||||
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
|
||||
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
|
||||
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
|
||||
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
|
||||
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
|
||||
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
|
||||
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
|
||||
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
|
||||
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893)
|
||||
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1789)
|
||||
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
|
||||
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
|
||||
at java.base/java.lang.Thread.run(Thread.java:834)
|
||||
@ -0,0 +1,162 @@
|
||||
2023-10-31 16:59:10,498 ERROR (DirectJDKLog.java:175)- Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
|
||||
java.lang.NullPointerException: null
|
||||
at com.leaper.pm2java.service.impl.Pm2JavaServiceImpl.stop(Pm2JavaServiceImpl.java:315)
|
||||
at com.leaper.pm2java.controller.AppCenterController.stop(AppCenterController.java:31)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
|
||||
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
|
||||
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
|
||||
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
|
||||
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1071)
|
||||
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:964)
|
||||
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
|
||||
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
|
||||
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
|
||||
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
|
||||
at javax.servlet.http.HttpServlet.service(HttpServlet.java:779)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
|
||||
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
|
||||
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
|
||||
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
|
||||
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
|
||||
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
|
||||
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
|
||||
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
|
||||
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
|
||||
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893)
|
||||
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1789)
|
||||
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
|
||||
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
|
||||
at java.base/java.lang.Thread.run(Thread.java:834)
|
||||
2023-10-31 16:59:42,356 ERROR (DirectJDKLog.java:175)- Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
|
||||
java.lang.NullPointerException: null
|
||||
at com.leaper.pm2java.service.impl.Pm2JavaServiceImpl.stop(Pm2JavaServiceImpl.java:315)
|
||||
at com.leaper.pm2java.controller.AppCenterController.stop(AppCenterController.java:31)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
|
||||
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
|
||||
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
|
||||
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
|
||||
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1071)
|
||||
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:964)
|
||||
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
|
||||
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
|
||||
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
|
||||
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
|
||||
at javax.servlet.http.HttpServlet.service(HttpServlet.java:779)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
|
||||
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
|
||||
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
|
||||
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
|
||||
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
|
||||
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
|
||||
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
|
||||
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
|
||||
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
|
||||
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893)
|
||||
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1789)
|
||||
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
|
||||
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
|
||||
at java.base/java.lang.Thread.run(Thread.java:834)
|
||||
2023-10-31 17:00:43,609 ERROR (DirectJDKLog.java:175)- Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
|
||||
java.lang.NullPointerException: null
|
||||
at com.leaper.pm2java.service.impl.Pm2JavaServiceImpl.stop(Pm2JavaServiceImpl.java:315)
|
||||
at com.leaper.pm2java.controller.AppCenterController.stop(AppCenterController.java:31)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
|
||||
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
|
||||
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
|
||||
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
|
||||
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1071)
|
||||
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:964)
|
||||
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
|
||||
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
|
||||
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
|
||||
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
|
||||
at javax.servlet.http.HttpServlet.service(HttpServlet.java:779)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
|
||||
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
|
||||
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
|
||||
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
|
||||
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
|
||||
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
|
||||
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
|
||||
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
|
||||
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
|
||||
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893)
|
||||
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1789)
|
||||
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
|
||||
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
|
||||
at java.base/java.lang.Thread.run(Thread.java:834)
|
||||
@ -0,0 +1,54 @@
|
||||
2023-11-01 16:34:13,230 ERROR (LoggingFailureAnalysisReporter.java:40)-
|
||||
|
||||
***************************
|
||||
APPLICATION FAILED TO START
|
||||
***************************
|
||||
|
||||
Description:
|
||||
|
||||
A component required a bean of type 'com.leaper.pm2java.util.ProcessBuilderUtil' that could not be found.
|
||||
|
||||
|
||||
Action:
|
||||
|
||||
Consider defining a bean of type 'com.leaper.pm2java.util.ProcessBuilderUtil' in your configuration.
|
||||
|
||||
2023-11-01 16:41:41,181 ERROR (LoggingFailureAnalysisReporter.java:40)-
|
||||
|
||||
***************************
|
||||
APPLICATION FAILED TO START
|
||||
***************************
|
||||
|
||||
Description:
|
||||
|
||||
A component required a bean of type 'com.leaper.pm2java.util.ProcessBuilderUtil' that could not be found.
|
||||
|
||||
|
||||
Action:
|
||||
|
||||
Consider defining a bean of type 'com.leaper.pm2java.util.ProcessBuilderUtil' in your configuration.
|
||||
|
||||
2023-11-01 16:42:21,132 ERROR (LoggingFailureAnalysisReporter.java:40)-
|
||||
|
||||
***************************
|
||||
APPLICATION FAILED TO START
|
||||
***************************
|
||||
|
||||
Description:
|
||||
|
||||
The dependencies of some of the beans in the application context form a cycle:
|
||||
|
||||
AppCenterController
|
||||
↓
|
||||
pm2JavaServiceImpl
|
||||
┌─────┐
|
||||
| webSocket
|
||||
↑ ↓
|
||||
| processBuilderUtil
|
||||
└─────┘
|
||||
|
||||
|
||||
Action:
|
||||
|
||||
Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
2023-11-02 11:20:48,952 ERROR (DirectJDKLog.java:175)- Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
|
||||
java.lang.NullPointerException: null
|
||||
at com.leaper.pm2java.service.impl.Pm2JavaServiceImpl.stop(Pm2JavaServiceImpl.java:319)
|
||||
at com.leaper.pm2java.controller.AppCenterController.stop(AppCenterController.java:31)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
|
||||
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
|
||||
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
|
||||
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
|
||||
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1071)
|
||||
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:964)
|
||||
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
|
||||
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
|
||||
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
|
||||
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
|
||||
at javax.servlet.http.HttpServlet.service(HttpServlet.java:779)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
|
||||
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
|
||||
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
|
||||
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
|
||||
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
|
||||
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
|
||||
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
|
||||
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
|
||||
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
|
||||
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893)
|
||||
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1789)
|
||||
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
|
||||
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
|
||||
at java.base/java.lang.Thread.run(Thread.java:834)
|
||||
@ -0,0 +1,18 @@
|
||||
2023-10-30 10:00:31,576 INFO (StartupInfoLogger.java:55)- Starting Pm2JavaApplication using Java 11.0.18 on LAPTOP-S9HJSOEB with PID 85000 (D:\git\pm2-java\target\classes started by 昊天 in D:\git\pm2-java)
|
||||
2023-10-30 10:00:31,577 INFO (SpringApplication.java:634)- No active profile set, falling back to 1 default profile: "default"
|
||||
2023-10-30 10:00:31,882 INFO (PostProcessorRegistrationDelegate.java:376)- Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$5914257a] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
|
||||
2023-10-30 10:00:31,897 INFO (AbstractAddressingEndpointMapping.java:239)- Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
|
||||
2023-10-30 10:00:32,020 INFO (TomcatWebServer.java:108)- Tomcat initialized with port(s): 9011 (http)
|
||||
2023-10-30 10:00:32,024 INFO (DirectJDKLog.java:173)- Initializing ProtocolHandler ["http-nio-9011"]
|
||||
2023-10-30 10:00:32,025 INFO (DirectJDKLog.java:173)- Starting service [Tomcat]
|
||||
2023-10-30 10:00:32,025 INFO (DirectJDKLog.java:173)- Starting Servlet engine: [Apache Tomcat/9.0.68]
|
||||
2023-10-30 10:00:32,072 INFO (DirectJDKLog.java:173)- Initializing Spring embedded WebApplicationContext
|
||||
2023-10-30 10:00:32,072 INFO (ServletWebServerApplicationContext.java:292)- Root WebApplicationContext: initialization completed in 477 ms
|
||||
2023-10-30 10:00:32,234 INFO (DirectJDKLog.java:173)- Starting ProtocolHandler ["http-nio-9011"]
|
||||
2023-10-30 10:00:32,243 INFO (TomcatWebServer.java:220)- Tomcat started on port(s): 9011 (http) with context path ''
|
||||
2023-10-30 10:00:32,249 INFO (StartupInfoLogger.java:61)- Started Pm2JavaApplication in 0.974 seconds (JVM running for 1.888)
|
||||
2023-10-30 10:00:32,269 INFO (InitService.java:18)- 服务查询
|
||||
2023-10-30 10:00:32,281 INFO (Pm2JavaServiceImpl.java:249)- ping服务启动
|
||||
2023-10-30 15:40:52,438 INFO (DirectJDKLog.java:173)- Initializing Spring DispatcherServlet 'dispatcherServlet'
|
||||
2023-10-30 15:40:52,440 INFO (FrameworkServlet.java:525)- Initializing Servlet 'dispatcherServlet'
|
||||
2023-10-30 15:40:52,458 INFO (FrameworkServlet.java:547)- Completed initialization in 18 ms
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
|
||||
@ -0,0 +1 @@
|
||||
{"args":["-jar",".\\web\\target\\duoji-1.0.0.jar"],"name":"java","path":"D:\\git\\hzleaper\\lia-monitor-backend","script":"javaw","type":2}
|
||||
@ -0,0 +1 @@
|
||||
{"args":["-jar",".\\web\\target\\duoji-1.0.0.jar"],"name":"java1","path":"D:\\git\\hzleaper\\lia-monitor-backend","script":"java","type":2}
|
||||
@ -0,0 +1 @@
|
||||
{"args":["127.0.0.1"],"argsString":"127.0.0.1","cpuProp":0,"cpuTime":0,"enable":false,"name":"ping","path":"","permanentlyDelete":false,"port":10,"ramProp":0,"reNumber":0,"script":"ping ","sessionNumber":0,"type":2}
|
||||
@ -0,0 +1,308 @@
|
||||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Apache Maven Wrapper startup batch script, version 3.2.0
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /usr/local/etc/mavenrc ] ; then
|
||||
. /usr/local/etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "$(uname)" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME
|
||||
else
|
||||
JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=$(java-config --jre-home)
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
|
||||
fi
|
||||
|
||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)"
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="$(which javac)"
|
||||
if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=$(which readlink)
|
||||
if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="$(dirname "\"$javaExecutable\"")"
|
||||
javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac"
|
||||
else
|
||||
javaExecutable="$(readlink -f "\"$javaExecutable\"")"
|
||||
fi
|
||||
javaHome="$(dirname "\"$javaExecutable\"")"
|
||||
javaHome=$(expr "$javaHome" : '\(.*\)/bin')
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=$(cd "$wdir/.." || exit 1; pwd)
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
printf '%s' "$(cd "$basedir" || exit 1; pwd)"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
# Remove \r in case we run on Windows within Git Bash
|
||||
# and check out the repository with auto CRLF management
|
||||
# enabled. Otherwise, we may read lines that are delimited with
|
||||
# \r\n and produce $'-Xarg\r' rather than -Xarg due to word
|
||||
# splitting rules.
|
||||
tr -s '\r\n' ' ' < "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
log() {
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
printf '%s\n' "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=$(find_maven_basedir "$(dirname "$0")")
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR
|
||||
log "$MAVEN_PROJECTBASEDIR"
|
||||
|
||||
##########################################################################################
|
||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
##########################################################################################
|
||||
wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
if [ -r "$wrapperJarPath" ]; then
|
||||
log "Found $wrapperJarPath"
|
||||
else
|
||||
log "Couldn't find $wrapperJarPath, downloading it ..."
|
||||
|
||||
if [ -n "$MVNW_REPOURL" ]; then
|
||||
wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||
else
|
||||
wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||
fi
|
||||
while IFS="=" read -r key value; do
|
||||
# Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
|
||||
safeValue=$(echo "$value" | tr -d '\r')
|
||||
case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;;
|
||||
esac
|
||||
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
log "Downloading from: $wrapperUrl"
|
||||
|
||||
if $cygwin; then
|
||||
wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
|
||||
fi
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
log "Found wget ... using wget"
|
||||
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet"
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||
else
|
||||
wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||
fi
|
||||
elif command -v curl > /dev/null; then
|
||||
log "Found curl ... using curl"
|
||||
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent"
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
|
||||
else
|
||||
curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
|
||||
fi
|
||||
else
|
||||
log "Falling back to using Java to download"
|
||||
javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class"
|
||||
# For Cygwin, switch paths to Windows format before running javac
|
||||
if $cygwin; then
|
||||
javaSource=$(cygpath --path --windows "$javaSource")
|
||||
javaClass=$(cygpath --path --windows "$javaClass")
|
||||
fi
|
||||
if [ -e "$javaSource" ]; then
|
||||
if [ ! -e "$javaClass" ]; then
|
||||
log " - Compiling MavenWrapperDownloader.java ..."
|
||||
("$JAVA_HOME/bin/javac" "$javaSource")
|
||||
fi
|
||||
if [ -e "$javaClass" ]; then
|
||||
log " - Running MavenWrapperDownloader.java ..."
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
# If specified, validate the SHA-256 sum of the Maven wrapper jar file
|
||||
wrapperSha256Sum=""
|
||||
while IFS="=" read -r key value; do
|
||||
case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;;
|
||||
esac
|
||||
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ -n "$wrapperSha256Sum" ]; then
|
||||
wrapperSha256Result=false
|
||||
if command -v sha256sum > /dev/null; then
|
||||
if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then
|
||||
wrapperSha256Result=true
|
||||
fi
|
||||
elif command -v shasum > /dev/null; then
|
||||
if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then
|
||||
wrapperSha256Result=true
|
||||
fi
|
||||
else
|
||||
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available."
|
||||
echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties."
|
||||
exit 1
|
||||
fi
|
||||
if [ $wrapperSha256Result = false ]; then
|
||||
echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
|
||||
echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2
|
||||
echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
|
||||
# Provide a "standardized" way to retrieve the CLI args that will
|
||||
# work with both Windows and non-Windows executions.
|
||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
|
||||
export MAVEN_CMD_LINE_ARGS
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
# shellcheck disable=SC2086 # safe args
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
$MAVEN_DEBUG_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||
@ -0,0 +1,205 @@
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM https://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Apache Maven Wrapper startup batch script, version 3.2.0
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
|
||||
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||
|
||||
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Found %WRAPPER_JAR%
|
||||
)
|
||||
) else (
|
||||
if not "%MVNW_REPOURL%" == "" (
|
||||
SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||
)
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %WRAPPER_URL%
|
||||
)
|
||||
|
||||
powershell -Command "&{"^
|
||||
"$webclient = new-object System.Net.WebClient;"^
|
||||
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
||||
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
||||
"}"^
|
||||
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
|
||||
"}"
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
|
||||
SET WRAPPER_SHA_256_SUM=""
|
||||
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B
|
||||
)
|
||||
IF NOT %WRAPPER_SHA_256_SUM%=="" (
|
||||
powershell -Command "&{"^
|
||||
"$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
|
||||
"If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
|
||||
" Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
|
||||
" Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
|
||||
" Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
|
||||
" exit 1;"^
|
||||
"}"^
|
||||
"}"
|
||||
if ERRORLEVEL 1 goto error
|
||||
)
|
||||
|
||||
@REM Provide a "standardized" way to retrieve the CLI args that will
|
||||
@REM work with both Windows and non-Windows executions.
|
||||
set MAVEN_CMD_LINE_ARGS=%*
|
||||
|
||||
%MAVEN_JAVA_EXE% ^
|
||||
%JVM_CONFIG_MAVEN_PROPS% ^
|
||||
%MAVEN_OPTS% ^
|
||||
%MAVEN_DEBUG_OPTS% ^
|
||||
-classpath %WRAPPER_JAR% ^
|
||||
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
|
||||
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
|
||||
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%"=="on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
|
||||
|
||||
cmd /C exit /B %ERROR_CODE%
|
||||
@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.7.5</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.leaper</groupId>
|
||||
<artifactId>pm2-java</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>pm2-java</name>
|
||||
<description>pm2-java</description>
|
||||
<properties>
|
||||
<java.version>11</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<!--json工具 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.47</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>2.3.1.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web-services</artifactId>
|
||||
<version>2.3.1.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-core</artifactId>
|
||||
<version>2.3.1.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
<version>2.3.1.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-test</artifactId>-->
|
||||
<!-- <scope>test</scope>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.28</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.3.1.RELEASE</version>
|
||||
<configuration>
|
||||
<includeSystemScope>true</includeSystemScope>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,19 @@
|
||||
package com.leaper.pm2java;
|
||||
|
||||
import com.leaper.pm2java.service.impl.Pm2JavaServiceImpl;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.web.socket.config.annotation.EnableWebSocket;
|
||||
|
||||
@EnableScheduling
|
||||
@SpringBootApplication
|
||||
@EnableWebSocket
|
||||
public class Pm2JavaApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Pm2JavaApplication.class, args);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.leaper.pm2java.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class CorsConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
//是否发送Cookie
|
||||
.allowCredentials(true)
|
||||
//放行哪些原始域
|
||||
.allowedOriginPatterns("*")
|
||||
.allowedHeaders("*")
|
||||
.exposedHeaders("*");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.leaper.pm2java.config;
|
||||
|
||||
import com.leaper.pm2java.service.impl.Pm2JavaServiceImpl;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Component
|
||||
public class MyCommandLineRunner implements CommandLineRunner {
|
||||
@Resource
|
||||
Pm2JavaServiceImpl pm2JavaService;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void preDestroy() {
|
||||
// 在这里编写要执行的最后操作
|
||||
System.out.println("最后执行的操作");
|
||||
for (String s : Pm2JavaServiceImpl.processBuilderMap.keySet()) {
|
||||
System.out.println("关闭process:" + s);
|
||||
pm2JavaService.stopByName(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package com.leaper.pm2java.controller;
|
||||
|
||||
|
||||
import com.leaper.pm2java.entity.AppServerEntity;
|
||||
import com.leaper.pm2java.entity.Result;
|
||||
import com.leaper.pm2java.service.Pm2JavaService;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RequestMapping(value = "/AppCenterController")
|
||||
@RestController(value = "AppCenterController")
|
||||
public class AppCenterController {
|
||||
|
||||
@Resource
|
||||
private Pm2JavaService pm2JavaService;
|
||||
|
||||
//启动
|
||||
@PostMapping("start")
|
||||
public Result start(@RequestBody AppServerEntity appServerEntity){
|
||||
pm2JavaService.start(appServerEntity);
|
||||
return Result.success();
|
||||
}
|
||||
//停止
|
||||
|
||||
@PostMapping("stop")
|
||||
public Result stop(@RequestBody AppServerEntity appServerEntity){
|
||||
pm2JavaService.stop(appServerEntity);
|
||||
return Result.success();
|
||||
}
|
||||
//重启
|
||||
@PostMapping("restart")
|
||||
public Result restart(@RequestBody AppServerEntity appServerEntity){
|
||||
pm2JavaService.stop(appServerEntity);
|
||||
pm2JavaService.start(appServerEntity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package com.leaper.pm2java.controller;
|
||||
|
||||
|
||||
import com.leaper.pm2java.entity.AppServerEntity;
|
||||
import com.leaper.pm2java.entity.AppServerInfo;
|
||||
import com.leaper.pm2java.entity.Result;
|
||||
import com.leaper.pm2java.service.Pm2JavaService;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RequestMapping(value = "/app")
|
||||
@RestController(value = "AppController")
|
||||
public class AppController {
|
||||
|
||||
@Resource
|
||||
private Pm2JavaService pm2JavaService;
|
||||
|
||||
//新增
|
||||
@PostMapping("installOrUpdateApp")
|
||||
public Result<List<AppServerInfo>> installApp(@RequestBody AppServerInfo appServerEntity){
|
||||
pm2JavaService.install(appServerEntity);
|
||||
return Result.success(pm2JavaService.select(null));
|
||||
}
|
||||
|
||||
//查找
|
||||
@PostMapping("select")
|
||||
public Result<List<AppServerInfo>> select(@RequestBody AppServerInfo appServerEntity){
|
||||
return Result.success(pm2JavaService.select(appServerEntity));
|
||||
}
|
||||
|
||||
//删
|
||||
@PostMapping("delete")
|
||||
public Result delete(@RequestBody AppServerInfo appServerEntity){
|
||||
pm2JavaService.delete(appServerEntity,appServerEntity.isPermanentlyDelete());
|
||||
return Result.success(pm2JavaService.select(null));
|
||||
}
|
||||
//删
|
||||
@PostMapping("remove")
|
||||
public Result remove(@RequestBody AppServerInfo appServerEntity){
|
||||
pm2JavaService.delete(appServerEntity,appServerEntity.isPermanentlyDelete());
|
||||
return Result.success(pm2JavaService.select(null));
|
||||
}
|
||||
|
||||
//搜索
|
||||
@PostMapping("search")
|
||||
public Result search(@RequestBody AppServerEntity appServerEntity){
|
||||
return Result.success(pm2JavaService.search());
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.leaper.pm2java.controller;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class LpTools {
|
||||
public static String encryptStr(String str) {
|
||||
BigInteger ulMacTmp = BigInteger.ZERO;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
ulMacTmp = ulMacTmp.shiftLeft(4);
|
||||
char cStr = str.charAt(i);
|
||||
if (cStr >= '0' && cStr <= '9')
|
||||
ulMacTmp = ulMacTmp.add(BigInteger.valueOf((int)(cStr - '0')));
|
||||
else if (cStr >= 'a' && cStr <= 'f')
|
||||
ulMacTmp = ulMacTmp.add(BigInteger.valueOf((int)(cStr - 'a' + 10)));
|
||||
else if (cStr >= 'A' && cStr <= 'F')
|
||||
ulMacTmp = ulMacTmp.add(BigInteger.valueOf((int)(cStr - 'A' + 10)));
|
||||
}
|
||||
str = ulMacTmp.toString();
|
||||
return str;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(LpTools.encryptStr("BFEBFBFF000B06710025_38BC_21C3_A29D."));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package com.leaper.pm2java.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.leaper.pm2java.entity.enums.ProcessStatus;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class AppServerInfo extends AppServerEntity implements Serializable {
|
||||
long cpuTime;
|
||||
//cpu使用比率万分之
|
||||
int cpuProp;
|
||||
//内存
|
||||
String ram;
|
||||
String argsString;
|
||||
//内存比例万分之
|
||||
int ramProp;
|
||||
|
||||
Long pid;
|
||||
String name;
|
||||
//状态
|
||||
ProcessStatus processStatus;
|
||||
//印象名称
|
||||
String imageName;
|
||||
//是否在线
|
||||
Boolean onOff ;
|
||||
//启动后重启次数
|
||||
Integer reNumber =0;
|
||||
|
||||
String sessionName;
|
||||
int sessionNumber;
|
||||
boolean permanentlyDelete;
|
||||
|
||||
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime selectTime;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.leaper.pm2java.entity;
|
||||
|
||||
|
||||
public enum HttpStatus {
|
||||
SUCCESS(200, "SUCCESS"),
|
||||
UNAUTHORIZED(401, "未认证"),
|
||||
INTERNAL_SERVER_ERROR(500, "内部异常,请联系管理员");
|
||||
|
||||
private final int code;
|
||||
private final String reasonPhrase;
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String getReasonPhrase() {
|
||||
return this.reasonPhrase;
|
||||
}
|
||||
|
||||
private HttpStatus(int code, String reasonPhrase) {
|
||||
this.code = code;
|
||||
this.reasonPhrase = reasonPhrase;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,177 @@
|
||||
package com.leaper.pm2java.entity;
|
||||
|
||||
|
||||
public class Result<T> {
|
||||
private Integer code;
|
||||
private String message;
|
||||
private T data;
|
||||
|
||||
public Result(T data) {
|
||||
this.code = HttpStatus.SUCCESS.getCode();
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static <T> Result<T> success(T data) {
|
||||
Result<T> result = new Result();
|
||||
result.setData(data);
|
||||
result.setCode(HttpStatus.SUCCESS.getCode());
|
||||
result.setMessage("SUCCESS");
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> Result<T> success(T data, String msg) {
|
||||
Result<T> result = new Result();
|
||||
result.setData(data);
|
||||
result.setCode(HttpStatus.SUCCESS.getCode());
|
||||
result.setMessage(msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Result success() {
|
||||
return builder().code(HttpStatus.SUCCESS.getCode()).message("SUCCESS").build();
|
||||
}
|
||||
|
||||
public static <T> Result<T> error(Integer code, String message) {
|
||||
Result<T> result = new Result();
|
||||
result.setCode(code);
|
||||
result.setMessage(message);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> ResultBuilder<T> builder() {
|
||||
return new ResultBuilder();
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
} else if (!(o instanceof Result)) {
|
||||
return false;
|
||||
} else {
|
||||
Result<?> other = (Result)o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
} else {
|
||||
label47: {
|
||||
Object this$code = this.getCode();
|
||||
Object other$code = other.getCode();
|
||||
if (this$code == null) {
|
||||
if (other$code == null) {
|
||||
break label47;
|
||||
}
|
||||
} else if (this$code.equals(other$code)) {
|
||||
break label47;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Object this$message = this.getMessage();
|
||||
Object other$message = other.getMessage();
|
||||
if (this$message == null) {
|
||||
if (other$message != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this$message.equals(other$message)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Object this$data = this.getData();
|
||||
Object other$data = other.getData();
|
||||
if (this$data == null) {
|
||||
if (other$data != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this$data.equals(other$data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean canEqual(Object other) {
|
||||
return other instanceof Result;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result = 1;
|
||||
Object $code = this.getCode();
|
||||
result = result * 59 + ($code == null ? 43 : $code.hashCode());
|
||||
Object $message = this.getMessage();
|
||||
result = result * 59 + ($message == null ? 43 : $message.hashCode());
|
||||
Object $data = this.getData();
|
||||
result = result * 59 + ($data == null ? 43 : $data.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Result(code=" + this.getCode() + ", message=" + this.getMessage() + ", data=" + this.getData() + ")";
|
||||
}
|
||||
|
||||
public Result(Integer code, String message, T data) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Result() {
|
||||
}
|
||||
|
||||
public static class ResultBuilder<T> {
|
||||
private Integer code;
|
||||
private String message;
|
||||
private T data;
|
||||
|
||||
ResultBuilder() {
|
||||
}
|
||||
|
||||
public ResultBuilder<T> code(Integer code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBuilder<T> message(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBuilder<T> data(T data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Result<T> build() {
|
||||
return new Result(this.code, this.message, this.data);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Result.ResultBuilder(code=" + this.code + ", message=" + this.message + ", data=" + this.data + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.leaper.pm2java.entity;
|
||||
|
||||
public class ServerEntity {
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.leaper.pm2java.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WebSocketConn {
|
||||
String uid;
|
||||
String appName;
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.leaper.pm2java.entity.enums;
|
||||
|
||||
public enum ProcessStatus {
|
||||
RUNNING("RUNNING"),
|
||||
SUSPENDED("SUSPENDED"),
|
||||
STOPPED("STOPPED"),
|
||||
UNKNOWN("UNKNOWN");
|
||||
String name;
|
||||
ProcessStatus(String name){
|
||||
this.name = name;
|
||||
}
|
||||
public static ProcessStatus fromValue(String value) {
|
||||
for (ProcessStatus processStatus : ProcessStatus.values()) {
|
||||
if (processStatus.name.equalsIgnoreCase(value)) {
|
||||
return processStatus;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid day value: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
package com.leaper.pm2java.service;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class InitService implements ApplicationRunner {
|
||||
@Resource
|
||||
Pm2JavaService pm2JavaService;
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
pm2JavaService.search();
|
||||
log.info("服务查询");
|
||||
for (String name :pm2JavaService.getAppServerInfoRecordMap().keySet()){
|
||||
if(pm2JavaService.getAppServerInfoRecordMap().get(name).getEnable() != null
|
||||
&& pm2JavaService.getAppServerInfoRecordMap().get(name).getEnable()){
|
||||
pm2JavaService.start(pm2JavaService.getAppServerInfoRecordMap().get(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package com.leaper.pm2java.service;
|
||||
|
||||
import com.leaper.pm2java.entity.AppServerEntity;
|
||||
import com.leaper.pm2java.entity.AppServerInfo;
|
||||
import com.leaper.pm2java.entity.WebSocketConn;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface Pm2JavaService {
|
||||
Map<String, AppServerInfo> getAppServerInfoRecordMap();
|
||||
|
||||
//新增服务管理,通过前端新增进行保存,数据持久化为文档,暂时不使用数据库
|
||||
public void install(AppServerInfo appConfigEntity);
|
||||
|
||||
//删除服务管理
|
||||
void delete(AppServerEntity appConfigEntity,boolean permanently );
|
||||
|
||||
//修改服务管理
|
||||
void update(AppServerEntity appConfigEntity);
|
||||
|
||||
//重置服务管理
|
||||
void reset(AppServerEntity appConfigEntity);
|
||||
|
||||
//查找
|
||||
List<AppServerInfo> select(AppServerInfo appConfigEntity);
|
||||
|
||||
//查询服务管理
|
||||
//同时扫描指定文件夹下历史情况
|
||||
public List<AppServerInfo> search ();
|
||||
//查询服务管理
|
||||
void start(AppServerEntity appConfigEntity);
|
||||
|
||||
void remove(AppServerInfo appConfigEntity);
|
||||
|
||||
|
||||
boolean status(long pid);
|
||||
//查询服务管理
|
||||
void stop(AppServerEntity appConfigEntity);
|
||||
|
||||
void sendLog(WebSocketConn webSocketConn);
|
||||
|
||||
}
|
||||
@ -0,0 +1,358 @@
|
||||
package com.leaper.pm2java.service.impl;
|
||||
|
||||
import com.leaper.pm2java.entity.AppServerEntity;
|
||||
import com.leaper.pm2java.entity.AppServerInfo;
|
||||
import com.leaper.pm2java.entity.WebSocketConn;
|
||||
import com.leaper.pm2java.entity.enums.ProcessStatus;
|
||||
import com.leaper.pm2java.service.Pm2JavaService;
|
||||
import com.leaper.pm2java.util.FileUtil;
|
||||
import com.leaper.pm2java.util.ProcessBuilderUtil;
|
||||
import com.leaper.pm2java.util.TimeUtil;
|
||||
import com.leaper.pm2java.websocket.WebSocket;
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.xml.crypto.Data;
|
||||
import java.io.*;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class Pm2JavaServiceImpl implements Pm2JavaService {
|
||||
|
||||
@Resource
|
||||
WebSocket webSocket;
|
||||
//现存的进程记录
|
||||
public static Map<String, Process> processBuilderMap = new ConcurrentHashMap<>();
|
||||
|
||||
//记录的应用程序情况
|
||||
public static Map<String, AppServerInfo> appServerInfoRecordMap = new ConcurrentHashMap<>();
|
||||
//创建一个固定线程个数的线程池
|
||||
ExecutorService executor = Executors.newFixedThreadPool(10);
|
||||
|
||||
|
||||
//创建一个webSocket线程个数的线程池
|
||||
ExecutorService executorWeb = Executors.newFixedThreadPool(10);
|
||||
|
||||
public Map<String, AppServerInfo> getAppServerInfoRecordMap() {
|
||||
return appServerInfoRecordMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void install(AppServerInfo appConfigEntity) {
|
||||
if (appConfigEntity.getArgsString() != null) {
|
||||
appConfigEntity.setArgs(appConfigEntity.getArgsString().split(","));
|
||||
}
|
||||
FileUtil.saveFile(appConfigEntity);
|
||||
|
||||
AppServerInfo appServerInfo = new AppServerInfo();
|
||||
appServerInfo.setName(appConfigEntity.getName());
|
||||
appServerInfo.setPath(appConfigEntity.getPath());
|
||||
appServerInfo.setArgs(appConfigEntity.getArgs());
|
||||
appServerInfo.setScript(appConfigEntity.getScript());
|
||||
appServerInfo.setType(appConfigEntity.getType());
|
||||
appServerInfo.setPort(appConfigEntity.getPort());
|
||||
appServerInfo.setEnable(appConfigEntity.getEnable());
|
||||
appServerInfoRecordMap.put(appServerInfo.getName(), appServerInfo);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(AppServerEntity appConfigEntity, boolean permanently) {
|
||||
//停止服务
|
||||
if (processBuilderMap.get(appConfigEntity.getName()) != null) {
|
||||
stop(appConfigEntity);
|
||||
}
|
||||
//删除内存记录
|
||||
appServerInfoRecordMap.remove(appConfigEntity.getName());
|
||||
if (permanently) {
|
||||
FileUtil.deleteFile(appConfigEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update(AppServerEntity appConfigEntity) {
|
||||
|
||||
FileUtil.saveFile(appConfigEntity);
|
||||
|
||||
AppServerInfo appServerInfo = new AppServerInfo();
|
||||
appServerInfo.setName(appConfigEntity.getName());
|
||||
appServerInfo.setPath(appConfigEntity.getPath());
|
||||
appServerInfo.setArgs(appConfigEntity.getArgs());
|
||||
appServerInfo.setScript(appConfigEntity.getScript());
|
||||
appServerInfo.setType(appConfigEntity.getType());
|
||||
appServerInfo.setPort(appConfigEntity.getPort());
|
||||
appServerInfo.setEnable(appConfigEntity.getEnable());
|
||||
appServerInfoRecordMap.put(appServerInfo.getName(), appServerInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(AppServerEntity appConfigEntity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppServerInfo> select(AppServerInfo appServerInfo) {
|
||||
List<AppServerInfo> list = appServerInfoRecordMap.keySet().stream()
|
||||
.peek(appName -> {
|
||||
if (processBuilderMap.get(appName) != null) {
|
||||
appServerInfoRecordMap.put(appName, searchNew(appServerInfoRecordMap.get(appName), appName));
|
||||
}
|
||||
})
|
||||
.filter(name -> {//名字搜索
|
||||
if (appServerInfo != null && appServerInfo.getName() != null) {
|
||||
return name.contains(appServerInfo.getName());
|
||||
} else return true;
|
||||
})
|
||||
.filter(name -> {
|
||||
if (appServerInfo != null && appServerInfo.getOnOff() != null) {
|
||||
return appServerInfoRecordMap.get(name).getOnOff() == (appServerInfo.getOnOff());
|
||||
} else return true;
|
||||
})
|
||||
.map(name -> {
|
||||
return appServerInfoRecordMap.get(name);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppServerInfo> search() {
|
||||
List<AppServerInfo> appServerInfos = new ArrayList<>();
|
||||
List<AppServerEntity> appServerEntities = FileUtil.readFile();
|
||||
for (AppServerEntity appServerEntity : appServerEntities) {
|
||||
AppServerInfo appServerInfo = new AppServerInfo();
|
||||
appServerInfo.setName(appServerEntity.getName());
|
||||
appServerInfo.setPath(appServerEntity.getPath());
|
||||
appServerInfo.setArgs(appServerEntity.getArgs());
|
||||
appServerInfo.setScript(appServerEntity.getScript());
|
||||
appServerInfo.setType(appServerEntity.getType());
|
||||
appServerInfo.setEnable(appServerEntity.getEnable());
|
||||
appServerInfo.setPort(appServerEntity.getPort());
|
||||
|
||||
appServerInfoRecordMap.put(appServerInfo.getName(), appServerInfo);
|
||||
}
|
||||
for (String appName : appServerInfoRecordMap.keySet()) {
|
||||
if (processBuilderMap.get(appName) != null) {
|
||||
appServerInfoRecordMap.get(appName).setOnOff(true);
|
||||
appServerInfos.add(searchNew(appServerInfoRecordMap.get(appName), appName));
|
||||
} else {
|
||||
appServerInfoRecordMap.get(appName).setOnOff(false);
|
||||
appServerInfos.add(appServerInfoRecordMap.get(appName));
|
||||
}
|
||||
}
|
||||
return appServerInfos;
|
||||
}
|
||||
|
||||
public AppServerInfo searchNew(AppServerInfo appServerInfo, String appName) {
|
||||
appServerInfo.setOnOff(true);
|
||||
appServerInfo.setName(appName);
|
||||
appServerInfo.setSelectTime(LocalDateTime.now());
|
||||
ProcessBuilder processBuilder = new ProcessBuilder("taskList", "/NH", "/V", "/FI", "\"PID eq " + processBuilderMap.get(appName).pid() + "\"");
|
||||
Process process = null;
|
||||
try {
|
||||
process = processBuilder.start();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), "gbk"));
|
||||
String line = reader.readLine();
|
||||
while (true) {
|
||||
// 排除首行和分隔线
|
||||
if (line.startsWith("Image Name") || line.startsWith("=") || "".equals(line)) {
|
||||
line = reader.readLine();
|
||||
System.out.println(line);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 使用制表符分割每一列的值
|
||||
String[] columns = line.split("\\s+");
|
||||
if (columns.length < 9) {
|
||||
return appServerInfo; // 无效的行
|
||||
}
|
||||
//映像名称
|
||||
String imageName = columns[0].trim();
|
||||
appServerInfo.setImageName(imageName);
|
||||
//会话名
|
||||
String sessionName = columns[2].trim();
|
||||
appServerInfo.setSessionName(sessionName);
|
||||
//会话#
|
||||
int sessionNumber = Integer.parseInt(columns[3].trim());
|
||||
appServerInfo.setSessionNumber(sessionNumber);
|
||||
|
||||
appServerInfo.setPid(processBuilderMap.get(appName).pid());
|
||||
//内存
|
||||
String ram = columns[4].trim();
|
||||
appServerInfo.setRam(ram);
|
||||
//状态
|
||||
String processStatus = columns[6].trim();
|
||||
appServerInfo.setProcessStatus(ProcessStatus.fromValue(processStatus));
|
||||
//cpu时间
|
||||
long cpuTime = TimeUtil.convertTimeToSeconds(columns[8].trim());
|
||||
appServerInfo.setCpuTime(cpuTime);
|
||||
System.out.println(appServerInfo);
|
||||
/*//计算cpu比例
|
||||
if(appServerInfoRecordMap.get(appServerInfo.getName())!= null){
|
||||
AppServerInfo appServerInfoOld = appServerInfoRecordMap.get(appServerInfo.getName());
|
||||
Duration duration = Duration.between(appServerInfoOld.getStartTime(), appServerInfo.getStartTime()).abs();
|
||||
long seconds = duration.getSeconds();
|
||||
if(seconds <= 5){
|
||||
}
|
||||
}*/
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
appServerInfoRecordMap.put(appServerInfo.getName(), appServerInfo);
|
||||
return appServerInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean status(long pid) {
|
||||
ProcessBuilder processBuilder = new ProcessBuilder("tasklist", "/fi", "PID eq " + pid);
|
||||
Process process = null;
|
||||
try {
|
||||
process = processBuilder.start();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (line.contains(" " + pid + " ")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(AppServerInfo appConfigEntity) {
|
||||
Integer number = appConfigEntity.getReNumber();
|
||||
stop(appConfigEntity);
|
||||
start(appConfigEntity);
|
||||
log.info(appConfigEntity.getName()+"服务重启");
|
||||
appServerInfoRecordMap.get(appConfigEntity.getName()).setReNumber(number++);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void start(AppServerEntity appConfigEntity) {
|
||||
if (processBuilderMap.get(appConfigEntity.getName()) != null) {
|
||||
return;
|
||||
}
|
||||
Future future = executor.submit(() -> {
|
||||
try {
|
||||
List<String> cmd = new ArrayList<String>();
|
||||
cmd.add("cmd");
|
||||
cmd.add("/c");
|
||||
cmd.add(appConfigEntity.getScript());
|
||||
if (null != appConfigEntity.getArgs() && appConfigEntity.getArgs().length != 0) {
|
||||
cmd.addAll(Arrays.asList(appConfigEntity.getArgs()));
|
||||
}
|
||||
// 创建 ProcessBuilder 对象,并设置要执行的命令
|
||||
ProcessBuilder pb = new ProcessBuilder(cmd);
|
||||
pb.directory(new File(appConfigEntity.getPath()));
|
||||
// 将标准输出和错误输出合并
|
||||
pb.redirectErrorStream(true);
|
||||
pb.environment().put("LANG", "zh_CN.UTF-8");
|
||||
Process process = pb.start();
|
||||
//关闭时允许您在JVM关闭之前执行特定的代码
|
||||
|
||||
// 启动命令并获取 Process 对象
|
||||
processBuilderMap.put(appConfigEntity.getName(), process);
|
||||
processBuilderMap.put(appConfigEntity.getName(), process);
|
||||
appServerInfoRecordMap.get(appConfigEntity.getName()).setOnOff(true);
|
||||
appServerInfoRecordMap.get(appConfigEntity.getName()).setSelectTime(LocalDateTime.now());
|
||||
log.info("{}服务启动", appConfigEntity.getName());
|
||||
//ProcessBuilderUtil.getProcessLogs(processBuilderMap.get(appConfigEntity.getName()));
|
||||
// 等待命令执行完成
|
||||
int exitCode = process.waitFor();
|
||||
System.out.println();
|
||||
log.info(appConfigEntity.getName()+"服务退出,命令退出码:" + exitCode);
|
||||
processBuilderMap.remove(appConfigEntity.getName());
|
||||
if(appServerInfoRecordMap.get(appConfigEntity.getName()).getOnOff() && appConfigEntity.getEnableRestart()){
|
||||
start(appConfigEntity);
|
||||
appServerInfoRecordMap.get(appConfigEntity.getName()).setReNumber(appServerInfoRecordMap.get(appConfigEntity.getName()).getReNumber()+1);
|
||||
}else {
|
||||
appServerInfoRecordMap.get(appConfigEntity.getName()).setReNumber(0);
|
||||
}
|
||||
appServerInfoRecordMap.get(appConfigEntity.getName()).setOnOff(false);
|
||||
appServerInfoRecordMap.get(appConfigEntity.getName()).setPid(null);
|
||||
appServerInfoRecordMap.get(appConfigEntity.getName()).setStartTime(null);
|
||||
appServerInfoRecordMap.get(appConfigEntity.getName()).setRam(null);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (processBuilderMap.get(appConfigEntity.getName()) != null) {
|
||||
processBuilderMap.get(appConfigEntity.getName()).destroyForcibly();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void stopByName(String name) {
|
||||
stop(appServerInfoRecordMap.get(name));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(AppServerEntity appConfigEntity) {
|
||||
// 创建 ProcessBuilder 对象,并设置要执行的命令
|
||||
ProcessBuilder pb = new ProcessBuilder("taskkill", "/f", "/t", "/pid", String.valueOf(processBuilderMap.get(appConfigEntity.getName()).pid())); // 将标准输出和错误输出合并
|
||||
pb.redirectErrorStream(true);
|
||||
pb.environment().put("LANG", "zh_CN.UTF-8");
|
||||
Process process = null;
|
||||
try {
|
||||
process = pb.start();
|
||||
appServerInfoRecordMap.get(appConfigEntity.getName()).setOnOff(false);
|
||||
// 等待命令执行完成
|
||||
int exitCode = process.waitFor();
|
||||
System.out.println("命令退出码:" + exitCode);
|
||||
log.info("{}服务停止", appConfigEntity.getName());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendLog(WebSocketConn webSocketConn) {
|
||||
executorWeb.submit(() -> {
|
||||
if (webSocket.getUserIds().contains(webSocketConn.getUid())) {
|
||||
Process process = processBuilderMap.get(webSocketConn.getAppName());
|
||||
|
||||
// 获取命令的输出流
|
||||
InputStream inputStream = process.getInputStream();
|
||||
|
||||
try {
|
||||
// 读取输出流内容
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "gbk"));
|
||||
String line;
|
||||
StringBuilder output = new StringBuilder();
|
||||
while (true) {
|
||||
if ((line = reader.readLine()) == null) break;
|
||||
webSocket.sendOneMessage(webSocketConn.getUid(), new String(line.getBytes(), StandardCharsets.UTF_8));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.leaper.pm2java.service.impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
public class Scheduling {
|
||||
@Resource
|
||||
Pm2JavaServiceImpl pm2JavaService;
|
||||
//
|
||||
// @Scheduled(cron = "*/15 * * * * *")
|
||||
// public void getNameLimit2() {
|
||||
// for (String processName :Pm2JavaServiceImpl.processBuilderMap.keySet()){
|
||||
// if(!pm2JavaService.status(Pm2JavaServiceImpl.processBuilderMap.get(processName).pid())){
|
||||
// pm2JavaService.restart(Pm2JavaServiceImpl.appServerInfoRecordMap.get(processName));
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
package com.leaper.pm2java.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.leaper.pm2java.entity.AppServerEntity;
|
||||
import com.leaper.pm2java.service.impl.Pm2JavaServiceImpl;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class FileUtil {
|
||||
static String confPath = "/appConf/";
|
||||
static String appSuffix = ".appConf";
|
||||
|
||||
//持久化记录为文件
|
||||
static public boolean saveFile(AppServerEntity appConfigEntity) {
|
||||
appConfigEntity.setType(2);
|
||||
String json = JSONObject.toJSONString(appConfigEntity);
|
||||
String currentFolder = System.getProperty("user.dir");
|
||||
String filePath = currentFolder + confPath;
|
||||
|
||||
File folder = new File(filePath);
|
||||
if (!folder.exists()) {
|
||||
folder.mkdirs();
|
||||
}
|
||||
|
||||
try (PrintWriter writer = new PrintWriter(new FileWriter(filePath + appConfigEntity.getName() + appSuffix))) {
|
||||
writer.write(json);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
AppServerEntity appConfigEntity = new AppServerEntity();
|
||||
appConfigEntity.setPath("D:\\git\\hzleaper\\lia-monitor-backend");
|
||||
appConfigEntity.setScript("javaw");
|
||||
appConfigEntity.setName("java");
|
||||
appConfigEntity.setArgs(new String[]{"-jar", ".\\web\\target\\duoji-1.0.0.jar"});
|
||||
saveFile(appConfigEntity);
|
||||
}
|
||||
|
||||
static public boolean deleteFile(AppServerEntity appConfigEntity) {
|
||||
String json = JSONObject.toJSONString(appConfigEntity);
|
||||
String currentFolder = System.getProperty("user.dir");
|
||||
String filePath = currentFolder + confPath + appConfigEntity.getName() + appSuffix;
|
||||
|
||||
File folder = new File(filePath);
|
||||
folder.delete();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
//持久化记录为文件
|
||||
static public List<AppServerEntity> readFile() {
|
||||
|
||||
String currentFolder = System.getProperty("user.dir");
|
||||
File folder = new File(currentFolder + confPath);
|
||||
File[] files = folder.listFiles();
|
||||
List<AppServerEntity> list = new ArrayList<>();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if (file.getName().endsWith(appSuffix)) {
|
||||
|
||||
// 读取文件内容
|
||||
try {
|
||||
String json = Files.readString(file.toPath());
|
||||
AppServerEntity appServerEntity = JSONObject.parseObject(json, AppServerEntity.class);
|
||||
list.add(appServerEntity);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,93 @@
|
||||
package com.leaper.pm2java.util;
|
||||
import java.io.*;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class MyService {
|
||||
public void onStart() {
|
||||
// 启动服务逻辑
|
||||
System.out.println("MyService started");
|
||||
}
|
||||
|
||||
public void onStop() {
|
||||
// 停止服务逻辑
|
||||
System.out.println("MyService stopped");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String command = args.length > 0 ? args[0] : "";
|
||||
String serviceName = "MyCustomService";
|
||||
|
||||
if (command.equals("install")) {
|
||||
installService(serviceName);
|
||||
} else if (command.equals("uninstall")) {
|
||||
uninstallService(serviceName);
|
||||
} else {
|
||||
// 启动服务
|
||||
runService();
|
||||
}
|
||||
}
|
||||
|
||||
private static void installService(String serviceName) {
|
||||
Path currentPath = Paths.get("");
|
||||
String command = "sc create " + serviceName + " binPath= \"" + currentPath.toAbsolutePath() + "\" start= auto";
|
||||
|
||||
try {
|
||||
executeCommand(command);
|
||||
System.out.println("Service installed successfully.");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void uninstallService(String serviceName) {
|
||||
String command = "sc delete " + serviceName;
|
||||
|
||||
try {
|
||||
executeCommand(command);
|
||||
System.out.println("Service uninstalled successfully.");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void runService() {
|
||||
MyService service = new MyService();
|
||||
service.onStart();
|
||||
|
||||
// 等待停止命令
|
||||
waitForStopCommand();
|
||||
|
||||
service.onStop();
|
||||
}
|
||||
|
||||
private static void waitForStopCommand() {
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (line.equalsIgnoreCase("stop")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void executeCommand(String command) throws IOException {
|
||||
ProcessBuilder processBuilder = new ProcessBuilder("cmd.exe", "/c", command);
|
||||
Process process = processBuilder.start();
|
||||
int exitCode;
|
||||
|
||||
try {
|
||||
exitCode = process.waitFor();
|
||||
} catch (InterruptedException e) {
|
||||
throw new IOException("Error executing command: " + command, e);
|
||||
}
|
||||
|
||||
if (exitCode != 0) {
|
||||
throw new IOException("Command execution failed with exit code: " + exitCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
package com.leaper.pm2java.util;
|
||||
|
||||
import com.leaper.pm2java.entity.AppServerEntity;
|
||||
import com.leaper.pm2java.service.impl.Pm2JavaServiceImpl;
|
||||
import com.leaper.pm2java.websocket.WebSocket;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@Component
|
||||
public class ProcessBuilderUtil {
|
||||
|
||||
|
||||
public static Process getProcessLogs(Process process){
|
||||
|
||||
try {
|
||||
// 获取命令的输出流
|
||||
InputStream inputStream = process.getInputStream();
|
||||
|
||||
// 读取输出流内容
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "gbk"));
|
||||
String line;
|
||||
StringBuilder output = new StringBuilder();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
|
||||
System.out.println(new String(line.getBytes(), StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
// 输出命令执行的返回信息
|
||||
System.out.println("命令执行结果:" + output.toString());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return process;
|
||||
}
|
||||
|
||||
public static Long getPID(Process process){
|
||||
try {
|
||||
process = new ProcessBuilder("yourCommand").start(); // 启动一个新进程
|
||||
Field field = process.getClass().getDeclaredField("pid"); // 反射获取 pid 字段
|
||||
field.setAccessible(true);
|
||||
Long pid =Long.parseLong( field.get(process).toString()); // 获取 pid 值
|
||||
System.out.println("The PID of the new process is: " + pid);
|
||||
return pid;
|
||||
} catch (IOException | NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (process != null) {
|
||||
process.destroy();
|
||||
}
|
||||
}
|
||||
return -1L;
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.leaper.pm2java.util;
|
||||
|
||||
public class TimeUtil {
|
||||
|
||||
public static int convertTimeToSeconds(String timeString) {
|
||||
String[] parts = timeString.split(":");
|
||||
int hours = Integer.parseInt(parts[0]);
|
||||
int minutes = Integer.parseInt(parts[1]);
|
||||
int seconds = Integer.parseInt(parts[2]);
|
||||
|
||||
return hours * 3600 + minutes * 60 + seconds;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
spring:
|
||||
application:
|
||||
name: pm2-java
|
||||
mvc:
|
||||
servlet:
|
||||
path: /pm2-api
|
||||
cache:
|
||||
type: simple
|
||||
# --------本服务端口号
|
||||
server:
|
||||
port: 9011
|
||||
|
||||
logging:
|
||||
config: classpath:logback-spring.xml
|
||||
Loading…
Reference in New Issue