YangZhiJie vor 8 Jahren
Ursprung
Commit
cc102c6b6e

+ 18 - 0
config/applicationContext.xml

@@ -26,6 +26,7 @@
 				<ref bean="applicationSetting5" />
 				<ref bean="applicationSetting6" />
 				<ref bean="applicationSetting7" />
+				<ref bean="applicationSetting8" />
 			</list>
 		</property>
 	</bean>
@@ -58,6 +59,8 @@
 		<property name="installPath" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171218"></property>
 		<property name="startBatFile" value="start.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
+		<property name="monitorUrl" value="http://127.0.0.1:81/monitor"></property>
+		<property name="token" value="123456"></property>
 		<property name="autoUpdateFileNames">
 			<list>
 				<value>DingDingServer-0.0.1-SNAPSHOT</value>
@@ -81,6 +84,8 @@
 		<property name="installPath" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171218"></property>
 		<property name="startBatFile" value="start.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
+		<property name="monitorUrl" value="http://127.0.0.1:82/activiti/explorer/monitor"></property>
+		<property name="token" value="123456"></property>
 	</bean>
 	
 	<bean id="applicationSetting4" class="com.leanwo.management.model.ApplicationSetting">
@@ -88,6 +93,8 @@
 		<property name="installPath" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171218"></property>
 		<property name="startBatFile" value="start.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
+		<property name="monitorUrl" value="http://127.0.0.1:83/monitor"></property>
+		<property name="token" value="123456"></property>
 	</bean>
 	
 	<bean id="applicationSetting5" class="com.leanwo.management.model.ApplicationSetting">
@@ -95,6 +102,8 @@
 		<property name="installPath" value="C:\Users\YangZhiJie\Desktop\Servers\DingTalk_Server_20171218"></property>
 		<property name="startBatFile" value="start.bat"></property>
 		<property name="stopBatFile" value="stop.bat"></property>
+		<property name="monitorUrl" value="http://127.0.0.1:80/monitor"></property>
+		<property name="token" value="123456"></property>
 	</bean>
 	
 	<bean id="applicationSetting6" class="com.leanwo.management.model.ApplicationSetting">
@@ -111,6 +120,15 @@
 		<property name="stopBatFile" value="stop.bat"></property>
 	</bean>
 	
+	<bean id="applicationSetting8" class="com.leanwo.management.model.ApplicationSetting">
+		<property name="name" value="文件服务程序"></property>
+		<property name="installPath" value=""></property>
+		<property name="startBatFile" value=""></property>
+		<property name="stopBatFile" value=""></property>
+		<property name="monitorUrl" value="http://127.0.0.1:85/api/monitor"></property>
+		<property name="token" value="123456"></property>
+	</bean>
+	
 	<bean id="springUtil" class="org.leanwo.management.util.SpringUtil" />
 	<bean id="xmlConfigPathService" class="org.leanwo.management.util.XmlConfigPathService"/>
 	

+ 25 - 1
pom.xml

@@ -22,7 +22,6 @@
 			<scope>test</scope>
 		</dependency>
 
-
 		<dependency>
 			<groupId>org.slf4j</groupId>
 			<artifactId>slf4j-api</artifactId>
@@ -50,11 +49,36 @@
 			<artifactId>spring-beans</artifactId>
 			<version>5.0.1.RELEASE</version>
 		</dependency>
+		
+		<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-webmvc</artifactId>
+			<version>4.3.12.RELEASE</version>
+		</dependency>
+		
 		<dependency>
 		    <groupId>org.apache.commons</groupId>
 		    <artifactId>commons-exec</artifactId>
 		    <version>1.3</version>
 		</dependency>
+		
+		<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
+		<dependency>
+			<groupId>com.fasterxml.jackson.core</groupId>
+			<artifactId>jackson-core</artifactId>
+			<version>2.9.2</version>
+		</dependency>
+		<dependency>
+			<groupId>com.fasterxml.jackson.core</groupId>
+			<artifactId>jackson-databind</artifactId>
+			<version>2.9.2</version>
+		</dependency>
+		<dependency>
+			<groupId>com.fasterxml.jackson.core</groupId>
+			<artifactId>jackson-annotations</artifactId>
+			<version>2.9.2</version>
+		</dependency>
 	</dependencies>
 	
 	

+ 37 - 0
src/main/java/com/leanwo/management/ServerManagmentJFrame.java

@@ -20,6 +20,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.net.URL;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -42,6 +43,14 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.leanwo.management.util.AutoUpdateService;
 import org.leanwo.management.util.SpringUtil;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.http.client.SimpleClientHttpRequestFactory;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.web.client.RestTemplate;
 
 import com.leanwo.management.model.ApplicationSetting;
 import com.leanwo.management.model.ApplicationSettingCache;
@@ -392,6 +401,34 @@ public class ServerManagmentJFrame extends JFrame implements ActionListener {
 						}
 					}
 				}
+				
+				// 监控各个服务程序是否正在运行
+				String url = setting.getMonitorUrl();
+				String token = setting.getToken();
+				if(url == null || "".equals(url) || token == null || "".equals(token)){
+					continue;
+				}
+				RestTemplate restTemplate = new RestTemplate();		
+				restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
+				HttpHeaders headers = new HttpHeaders();
+				headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
+				headers.add("account", "2");
+				headers.add("token", token);
+				HttpEntity entity = new HttpEntity(headers);
+				try{			
+					ResponseEntity<Long> response = restTemplate.exchange(url, HttpMethod.GET, entity, Long.class);
+					((SimpleClientHttpRequestFactory)restTemplate.getRequestFactory()).setReadTimeout(1000*30);
+					((SimpleClientHttpRequestFactory)restTemplate.getRequestFactory()).setConnectTimeout(1000*30);
+					Long result = response.getBody();
+					long mills = new Date().getTime() - result;
+					if(statusLabel != null){
+						statusLabel.setText("运行中(" + mills + "ms)");
+					}
+				}catch(Exception ex){
+					if(statusLabel != null){
+						statusLabel.setText("已停止");
+					}
+				}
 			}
 		}
 	}

+ 47 - 6
src/main/java/com/leanwo/management/model/ApplicationSetting.java

@@ -39,6 +39,26 @@ public class ApplicationSetting {
 	 */
 	private String stopBatFile;
 	
+	/** The execute watchdog. */
+	private ExecuteWatchdog executeWatchdog;
+
+	/** 监控地址. */
+	private String monitorUrl;
+	
+	/** token. */
+	private String token;
+	
+	
+	
+	/**
+	 * Gets the token.
+	 *
+	 * @return the token
+	 */
+	public String getToken() {
+		return token;
+	}
+
 	/**
 	 * 自动更新的文件名.
 	 */
@@ -51,9 +71,30 @@ public class ApplicationSetting {
 	
 	
 	/**
-	 * 
+	 *
+	 * @param token the new token
+	 */
+	public void setToken(String token) {
+		this.token = token;
+	}
+
+	/**
+	 * Gets the 监控地址.
+	 *
+	 * @return the 监控地址
 	 */
-	private ExecuteWatchdog executeWatchdog;
+	public String getMonitorUrl() {
+		return monitorUrl;
+	}
+
+	/**
+	 * Sets the 监控地址.
+	 *
+	 * @param monitorUrl the new 监控地址
+	 */
+	public void setMonitorUrl(String monitorUrl) {
+		this.monitorUrl = monitorUrl;
+	}
 
 	
 	/**
@@ -129,18 +170,18 @@ public class ApplicationSetting {
 	}
 
 	/**
-	 * 
+	 * Gets the execute watchdog.
 	 *
-	 * @return 
+	 * @return the execute watchdog
 	 */
 	public ExecuteWatchdog getExecuteWatchdog() {
 		return executeWatchdog;
 	}
 
 	/**
-	 * 
+	 * Sets the execute watchdog.
 	 *
-	 * @param executeWatchdog 
+	 * @param executeWatchdog the new execute watchdog
 	 */
 	public void setExecuteWatchdog(ExecuteWatchdog executeWatchdog) {
 		this.executeWatchdog = executeWatchdog;