mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-02 20:08:40 +08:00
nginx重新加载
This commit is contained in:
parent
9df05bdce3
commit
38dd8dc74a
@ -284,11 +284,8 @@ public class NginxController extends BaseAgentController {
|
|||||||
public String reload() {
|
public String reload() {
|
||||||
if (SystemUtil.getOsInfo().isLinux()) {
|
if (SystemUtil.getOsInfo().isLinux()) {
|
||||||
String result = CommandUtil.execSystemCommand("nginx -t");
|
String result = CommandUtil.execSystemCommand("nginx -t");
|
||||||
List<String> strings = StrSpliter.splitTrim(result, "\n", true);
|
if (!result.endsWith("successful") || !result.endsWith("ok")) {
|
||||||
for (String str : strings) {
|
return JsonMessage.getString(400, result);
|
||||||
if (!str.endsWith("successful") || !str.endsWith("ok")) {
|
|
||||||
return JsonMessage.getString(400, result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
CommandUtil.execSystemCommand("nginx -s reload");
|
CommandUtil.execSystemCommand("nginx -s reload");
|
||||||
} else if (SystemUtil.getOsInfo().isWindows()) {
|
} else if (SystemUtil.getOsInfo().isWindows()) {
|
||||||
@ -297,22 +294,20 @@ public class NginxController extends BaseAgentController {
|
|||||||
String result = CommandUtil.execSystemCommand("sc qc " + name);
|
String result = CommandUtil.execSystemCommand("sc qc " + name);
|
||||||
List<String> strings = StrSpliter.splitTrim(result, "\n", true);
|
List<String> strings = StrSpliter.splitTrim(result, "\n", true);
|
||||||
//服务路径
|
//服务路径
|
||||||
String path = "";
|
File file = null;
|
||||||
for (String str : strings) {
|
for (String str : strings) {
|
||||||
str = str.toUpperCase().trim();
|
str = str.toUpperCase().trim();
|
||||||
if (str.startsWith("BINARY_PATH_NAME")) {
|
if (str.startsWith("BINARY_PATH_NAME")) {
|
||||||
path = str.substring(str.indexOf(":") + 1).replace("\"", "");
|
String path = str.substring(str.indexOf(":") + 1).replace("\"", "").trim();
|
||||||
|
file = FileUtil.file(path).getParentFile();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StrUtil.isEmpty(path)) {
|
|
||||||
return JsonMessage.getString(400, "未找到nginx路径");
|
|
||||||
}
|
|
||||||
File file = FileUtil.file(path).getParentFile();
|
|
||||||
result = CommandUtil.execSystemCommand("nginx -t", file);
|
result = CommandUtil.execSystemCommand("nginx -t", file);
|
||||||
if (StrUtil.isNotEmpty(result)) {
|
if (StrUtil.isNotEmpty(result)) {
|
||||||
return JsonMessage.getString(400, result);
|
return JsonMessage.getString(400, result);
|
||||||
}
|
}
|
||||||
|
CommandUtil.execSystemCommand("nginx -s reload", file);
|
||||||
}
|
}
|
||||||
return JsonMessage.getString(200, "重新加载成功");
|
return JsonMessage.getString(200, "重新加载成功");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user