From 96f560e3c9b256cb0f74b5d0a9f24d53794bcbc3 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Sun, 9 May 2021 00:15:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=81=9C=E6=AD=A2=E6=9C=8D=E5=8A=A1=E6=94=B9?= =?UTF-8?q?=E6=88=90=E9=87=8D=E5=90=AF=E6=9C=8D=E5=8A=A1=20maven=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=89=93=E5=8C=85=E5=88=B0=E6=9C=8D=E5=8A=A1=E7=AB=AF?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=88=E9=9C=80=E6=98=A0=E5=B0=84nas?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=88=B0z=E7=9B=98)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 21 +++++++++++ .../java/com/yutou/nas/utils/AppTools.java | 36 +++++++++++++++++-- .../com/yutou/nas/utils/QQBotManager.java | 10 +++--- .../java/com/yutou/nas/utils/RedisTools.java | 1 - 4 files changed, 60 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index e6d2122..dac4606 100644 --- a/pom.xml +++ b/pom.xml @@ -158,6 +158,27 @@ org.springframework.boot spring-boot-maven-plugin + + + ZIP + + com.yutou.nas.NasApplication + + + + package + + repackage + + + + + Z:\servier\tools\ + + + + + diff --git a/src/main/java/com/yutou/nas/utils/AppTools.java b/src/main/java/com/yutou/nas/utils/AppTools.java index 15b324a..ab783c8 100644 --- a/src/main/java/com/yutou/nas/utils/AppTools.java +++ b/src/main/java/com/yutou/nas/utils/AppTools.java @@ -3,8 +3,40 @@ package com.yutou.nas.utils; import java.text.SimpleDateFormat; import java.util.Date; +import static com.yutou.nas.utils.RedisTools.processOut; + public class AppTools { - public static String getToDayNowTimeToString(){ - return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + public static String getToDayNowTimeToString() { + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + } + + public static void exec(String exec) { + try { + Process process; + if (AppTools.isRuntimeSystemOfWindow()) { + process = Runtime.getRuntime().exec(new String[]{ + "cmd", + "/c", + exec + } + ); + } else { + process = Runtime.getRuntime().exec(new String[]{ + "sh", + "-c", + exec + } + ); + } + processOut(process.getInputStream()); + processOut(process.getErrorStream()); + process.destroy(); + }catch (Exception e){ + e.printStackTrace(); + } + } + + public static boolean isRuntimeSystemOfWindow() { + return System.getProperty("os.name").contains("Windows"); } } diff --git a/src/main/java/com/yutou/nas/utils/QQBotManager.java b/src/main/java/com/yutou/nas/utils/QQBotManager.java index 38f067c..beea263 100644 --- a/src/main/java/com/yutou/nas/utils/QQBotManager.java +++ b/src/main/java/com/yutou/nas/utils/QQBotManager.java @@ -30,7 +30,7 @@ public class QQBotManager { private static class QQCommands { private final static String QQ_HELP = "!help"; - private final static String QQ_SYSTEM_STOP = "!stop"; + private final static String QQ_SYSTEM_RESTART = "!restart"; private final static String QQ_UPDATE_IP = "!更新ip"; private final static String QQ_GET_IP = "!ip"; private final static String QQ_OPEN_PC = "!开机"; @@ -95,7 +95,7 @@ public class QQBotManager { } catch (InterruptedException e) { e.printStackTrace(); } - String str = sendMessage("姬妻酱上线拉~"); + String str = sendMessage("姬妻酱上线拉~☆Daze~"); com.yutou.nas.utils.Log.i(str); } @@ -259,10 +259,10 @@ public class QQBotManager { case QQCommands.QQ_BT_RELOAD: BTDownloadManager.getInstance().start(); break; - case QQCommands.QQ_SYSTEM_STOP: - getInstance().sendMessage("正在停止服务"); + case QQCommands.QQ_SYSTEM_RESTART: + getInstance().sendMessage("正在重启服务"); System.out.println("结束进程"); - System.exit(0); + AppTools.exec("cd /media/yutou/4t/public/servier/tools && ./start.sh"); break; case QQCommands.QQ_HELP: builder = new StringBuilder(); diff --git a/src/main/java/com/yutou/nas/utils/RedisTools.java b/src/main/java/com/yutou/nas/utils/RedisTools.java index 49f6785..fecff0d 100644 --- a/src/main/java/com/yutou/nas/utils/RedisTools.java +++ b/src/main/java/com/yutou/nas/utils/RedisTools.java @@ -290,7 +290,6 @@ public class RedisTools { } com.yutou.nas.utils.Log.i("cmd > " + str); QQBotManager.getInstance().sendMessage(str.toString()); - com.yutou.nas.utils.Log.i("线程结束"); } public static void main(String[] args) { RedisTools.pullMsg("msg", "abc");