Переглянути джерело

Merge branch 'master' of chenweida/esb into master

esb 9 роки тому
батько
коміт
b7786cfe16

+ 7 - 5
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/thread/UpdateThread.java

@ -201,9 +201,9 @@ public class UpdateThread implements Runnable {
        try {
            String system = System.getProperty("os.name").toLowerCase();
            if (system.contains("windows")) {
                LogUtil.info("启动windows服务");
                //windows
                String batPathStart = UpdateThread.class.getResource("/").getPath() + "config/start.bat";
                LogUtil.info("启动windows服务:" + batPathStart);
                //windows
                Process psStart = Runtime.getRuntime().exec(batPathStart);
                ByteArrayOutputStream baosStart = new ByteArrayOutputStream();
                InputStream osStart = psStart.getInputStream();
@ -213,8 +213,9 @@ public class UpdateThread implements Runnable {
                }
                osStart.close();
                baosStart.close();
                int i = 0;
                LogUtil.info("开始判断服务是否启动");
                while (true) {
                    int i = 0;
                    String batPath = UpdateThread.class.getResource("/").getPath() + "config/serviceAlive.bat";
                    Process ps = Runtime.getRuntime().exec(batPath);
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
@ -225,13 +226,13 @@ public class UpdateThread implements Runnable {
                    String s = baos.toString();
                    os.close();
                    baos.close();
                    LogUtil.info("服务正在启动:" + Boolean.valueOf(s.trim()));
                    if (Boolean.valueOf(s.trim())) {
                        i++;
                        if (i > 3) {
                            LogUtil.info("服务启动成功");
                            break;
                        }
                        LogUtil.info("第" + i + "次判断服务已经启动");
                        Thread.sleep(1000L);
                    }
                }
            } else {
@ -373,6 +374,7 @@ public class UpdateThread implements Runnable {
    public static void main(String[] args) throws Exception {
        while (true) {
            String batPath = UpdateThread.class.getResource("/").getPath() + "config/serviceAlive.bat";
            System.out.println(batPath);
            Process ps = Runtime.getRuntime().exec(batPath);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            InputStream os = ps.getInputStream();

+ 1 - 1
Hos-Resource-Mini-Update/src/main/resources/config/serviceAlive.bat

@ -1,5 +1,5 @@
@echo off
for /f "skip=3 tokens=4" %%i in ('sc query tomcat8-esb-ds') do set "zt=%%i" &goto :next
for /f "skip=3 tokens=4" %%i in ('sc query tomcat8-esb-ds ') do set "zt=%%i" &goto :next
:next
if /i "%zt%"=="RUNNING" (
    echo true

+ 8 - 6
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/thread/LogThread.java

@ -43,7 +43,7 @@ public class LogThread implements Runnable {
                            //发送日志文件
                            sendLogFile(file);
                            //删除日志文件
                            //deleteLogFile(file);
                            deleteLogFile(file);
                        }
                    }
                }
@ -96,7 +96,7 @@ public class LogThread implements Runnable {
            formParams.add(new BasicNameValuePair("access_token", token));
            formParams.add(new BasicNameValuePair("orgCode", orgCode));
            String booleanString = HttpsClientUtil.postFile(ThreadConfig.SERVICE_URL + ThreadConfig.LOG_THREAD_UPLOAD, file, formParams, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            LogUtil.info("日志发送成功:" + booleanString);
            LogUtil.info("日志上传结果:" + booleanString);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
@ -105,7 +105,8 @@ public class LogThread implements Runnable {
        }
    }
    private void deleteLogFile(File file) {
    private void deleteLogFile(String filePathTemp) {
        File file=new File(filePathTemp);
        String filePath = file.getAbsolutePath();
        if (file.delete()) {
            LogUtil.info("日志删除成功");
@ -117,10 +118,11 @@ public class LogThread implements Runnable {
    public String getLogFile() {
        String home = System.getProperty("catalina.home").replace('\\', '/');
        String srcPath = home.substring(0, home.lastIndexOf('/') + 1) +  "log4j";
        String srcPath = home.substring(0, home.lastIndexOf('/') + 1) + "log4j";
        LogUtil.info("压缩日志,日志目录:" + srcPath);
        String filePath = srcPath + File.separator + logFileName;
        ZipUtil.zip(srcPath, filePath);
        LogUtil.info("日志文件路径:" + filePath);
        LogUtil.info("上传的日志文件路径:" + filePath);
        File file = new File(filePath);
        if (file.exists()) {
            LogUtil.info("-----------得到日志成功------------");
@ -133,7 +135,7 @@ public class LogThread implements Runnable {
    private void sleep() throws Exception {
        LogUtil.info("日志线程开始睡眠,睡眠时间(分钟):" + ThreadConfig.LOG_THREAD_SLEEP_TIME);
        Thread.sleep(sleepTime * ThreadConfig.SQL_THREAD_SLEEP_TIME);
        Thread.sleep(sleepTime * ThreadConfig.LOG_THREAD_SLEEP_TIME);
    }
    public static void main(String[] args) {

+ 2 - 2
Hos-Resource-Mini-helper/src/main/resources/config/threadConfig.properties

@ -1,9 +1,9 @@
soft.versionCode=1
## service address
service.url=https://172.19.103.73:443:443/api/v1.0/
service.url=https://172.19.103.73:443/api/v1.0/
service.clientId = kHAbVppx44
service.clientKey = Bd2h8rdYhep6NKOO
logThread.sleepTime=30
logThread.sleepTime=1
sqlThread.sleepTime=30