fixed some bugs

This commit is contained in:
liuzhihang1
2024-06-29 22:26:47 +08:00
parent 8889c86e75
commit 7e2d6f420b
12 changed files with 203 additions and 17 deletions

7
.gitignore vendored
View File

@@ -1,3 +1,6 @@
info.log
xmp*
data.db
msm*
vue-minecraft/node_modules
data.db
.data*
config.yaml

50
README.md Normal file
View File

@@ -0,0 +1,50 @@
基于golang的进程管理工具
# 基础功能
- 类似screen的进程管理
- 提供web ui可视化操作
- 基于Elasticsearch的日志管理
- 三种角色的权限管理
- 进程性能监控
- 进程状态推送
# 终端类型
## pty
基于伪终端实现支持ansi字符、快捷键仅支持linux
## std
基于stdin、stdout管道实现支持所有平台
# 角色
| 角色 | 角色管理 | 进程创建 | 操控进程 | 日志查看 |
| ----- | -------- | -------- | -------- | ---- |
| root | ✔ | ✔ | ✔ | ✔ |
| admin | × | × | ✔ | ✔ |
| user | × | × | 需配置 | × |
# 如何使用
## 启动进程
### windows
下载windows版本双击运行
### linux
下载linux版本
使用命令
```
chmod 777 ./xpm
./xpm
```
## web界面
访问http://[ip]:8797
默认账号密码 root/root
# 界面
### 进程
![image](https://github.com/lzh-1625/x_process_manager/assets/59822923/50f31b99-41d4-4d8c-88fe-20c978385155)
### 终端
![image](https://github.com/lzh-1625/x_process_manager/assets/59822923/63eb6bec-353f-4d12-a1d9-95d89fccdac3)
### 日志
![image](https://github.com/lzh-1625/x_process_manager/assets/59822923/6af8e228-7709-45c5-aba8-4b61dc825026)

View File

@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>login</title><script defer="defer" src="/js/chunk-vendors.e8c75f7d.js"></script><script defer="defer" src="/js/app.eeb57861.js"></script><link href="/css/chunk-vendors.d0dc20f7.css" rel="stylesheet"><link href="/css/app.04e5ff9e.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but login doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>login</title><script defer="defer" src="/js/chunk-vendors.e8c75f7d.js"></script><script defer="defer" src="/js/app.d1a426cf.js"></script><link href="/css/chunk-vendors.d0dc20f7.css" rel="stylesheet"><link href="/css/app.04e5ff9e.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but login doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

128
server_config.json Normal file
View File

@@ -0,0 +1,128 @@
{
"user": [
{
"account": "admin",
"password": "91cd3b960f31c06fc4048ff44e6654c1"
},
{
"account": "user",
"password": "5f4dcc3b5aa765d61d8327deb882cf99"
}
],
"server": [
{
"name": "bungeecord",
"args": [
"/usr/lib/jvm/java-17-openjdk-amd64/bin/java",
"-Xmx580M",
"-Xms100M",
"-jar",
"waterfall-1.19-510.jar"
],
"cwd": "/MCS/BungeeCord",
"autoRestart": true,
"push": true,
"logReport": true
},
{
"name": "lobby",
"args": [
"java",
"-jar",
"-server",
"-Xmx1000M",
"paper-1.16.5-794.jar"
],
"cwd": "/MCS/lobby",
"autoRestart": true,
"push": true,
"logReport": true
},
{
"name": "main",
"args": [
"java",
"-jar",
"-server",
"-Xmx8000M",
"launcher-airplane.jar"
],
"cwd": "/MCS",
"autoRestart": true,
"push": true,
"logReport": true
},
{
"name": "s1",
"args": [
"java",
"-jar",
"-server",
"-Xmx5000M",
"launcher-airplane.jar"
],
"cwd": "/MCS/server1",
"autoRestart": true,
"push": true,
"logReport": true
},
{
"name": "起床战争bungeecord",
"args": [
"java",
"-jar",
"BB.jar"
],
"cwd": "/MCS/bed/[25565]BungeeCord",
"autoRestart": true
},
{
"name": "起床战争looby",
"args": [
"java",
"-jar",
"paper-1.16.5-794.jar"
],
"cwd": "/MCS/bed/[25566]Lobby",
"autoRestart": true
},
{
"name": "起床战争入侵",
"args": [
"/usr/lib/jvm/java-8-openjdk-amd64/bin/java",
"-jar",
"RQS.jar"
],
"cwd": "/MCS/bed/[20003]BedWars-入侵",
"autoRestart": true
},
{
"name": "起床战争蘑菇",
"args": [
"/usr/lib/jvm/java-8-openjdk-amd64/bin/java",
"-jar",
"PaperSpigot-1.8.8.jar"
],
"cwd": "/MCS/bed/[10002]BedWarsXP-蘑菇",
"autoRestart": true
}
],
"mq": {
"enable": true,
"mqurl": "amqp://admin:1625167628%40xcon@xcon.top:5672/",
"queue_name": "log_queue_publisher",
"exchange": "log_exchange_publisher",
"routing_key": "server_log"
},
"push": {
"feishu": {
"enable": true,
"webhook": "https://open.feishu.cn/open-apis/bot/v2/hook/86f491ba-6c7a-413b-86e6-d72420934bd9"
},
"wechat":{
"enable": true,
"webhook": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=5f3fae11-da5c-45a7-8ae9-ceaca2dc1495"
}
},
"logLevel": "debug"
}

View File

@@ -37,7 +37,7 @@ func InitEs() bool {
log.Logger.Error("es启动失败", err)
config.CF.EsEnable = false
} else {
return true
return true
}
} else {
log.Logger.Debug("不使用es")
@@ -121,12 +121,16 @@ func (e *esService) Search(req model.GetLogReq) model.LogResp {
func (e *esService) buildQueryBody(req model.GetLogReq) model.QueryBody {
result := model.QueryBody{}
if req.TimeRange.EndTime != 0 || req.TimeRange.StartTime != 0 {
time := map[string]any{}
if req.TimeRange.StartTime != 0 {
time["gte"] = req.TimeRange.StartTime
}
if req.TimeRange.EndTime != 0 {
time["lte"] = req.TimeRange.EndTime
}
result.Query.Bool.Must = append(result.Query.Bool.Must, map[string]any{
"range": map[string]any{
"time": map[string]any{
"gte": req.TimeRange.StartTime,
"lte": req.TimeRange.EndTime,
},
"time": time,
},
})
}

View File

@@ -7,6 +7,7 @@ import (
"msm/config"
"msm/log"
"msm/model"
"msm/utils"
"os/exec"
"strings"
"time"
@@ -107,7 +108,7 @@ func (p *ProcessStd) pInit() {
func (p *ProcessStd) ReadCache(ws *websocket.Conn) {
for _, line := range p.cacheLine {
ws.WriteMessage(websocket.BinaryMessage, []byte(line))
ws.WriteMessage(websocket.TextMessage, []byte(line))
}
}
@@ -128,7 +129,7 @@ func (p *ProcessStd) readInit() {
output = p.Read()
if p.IsUsing.Load() && output != "" {
p.ws.wsMux.Lock()
p.ws.wsConnect.WriteMessage(websocket.BinaryMessage, []byte(output))
p.ws.wsConnect.WriteMessage(websocket.TextMessage, []byte(output))
p.ws.wsMux.Unlock()
}
}
@@ -137,7 +138,7 @@ func (p *ProcessStd) readInit() {
}
func (p *ProcessStd) Read() string {
if p.stdout.Scan() {
output := p.stdout.Text()
output := utils.RemoveNotValidUtf8InString(p.stdout.Text())
p.logReportHandler(output)
p.cacheLine = p.cacheLine[1:]
p.cacheLine = append(p.cacheLine, output)