mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-12 06:45:46 +08:00
fix: 修复 无法关闭 web admin监听的问题
This commit is contained in:
parent
b0d5589dcd
commit
e3f0dbc4ac
@ -17,6 +17,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -69,6 +70,8 @@ func (s *webServer) Run(addr string, cli *client.QQClient) *coolq.CQBot {
|
|||||||
s.engine.Any("/admin/:action", s.admin)
|
s.engine.Any("/admin/:action", s.admin)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
//开启端口监听
|
||||||
|
if s.Conf.WebUi.Enabled{
|
||||||
log.Infof("Admin API 服务器已启动: %v", addr)
|
log.Infof("Admin API 服务器已启动: %v", addr)
|
||||||
err := s.engine.Run(addr)
|
err := s.engine.Run(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -77,6 +80,13 @@ func (s *webServer) Run(addr string, cli *client.QQClient) *coolq.CQBot {
|
|||||||
time.Sleep(time.Second * 5)
|
time.Sleep(time.Second * 5)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
//关闭端口监听
|
||||||
|
c := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(c, os.Interrupt, os.Kill)
|
||||||
|
<-c
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
s.Dologin()
|
s.Dologin()
|
||||||
s.UpServer()
|
s.UpServer()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user