|
|
@@ -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;
|
|
|
@@ -40,6 +41,14 @@ import org.apache.commons.exec.PumpStreamHandler;
|
|
|
import org.apache.commons.logging.Log;
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
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;
|
|
|
@@ -324,6 +333,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("已停止");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|