mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 04:10:27 +08:00
修复缓存策略页面空白的问题/stop命令改成QUIT信号
This commit is contained in:
3
cmd/edge-admin/build.sh
Executable file
3
cmd/edge-admin/build.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
env GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o edge-admin main.go
|
||||||
BIN
cmd/edge-admin/edge-admin
Executable file
BIN
cmd/edge-admin/edge-admin
Executable file
Binary file not shown.
@@ -8,6 +8,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -199,7 +200,7 @@ func (this *AppCmd) runStop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 停止进程
|
// 停止进程
|
||||||
_ = proc.Kill()
|
_ = proc.Signal(syscall.SIGQUIT)
|
||||||
|
|
||||||
// 在Windows上经常不能及时释放资源
|
// 在Windows上经常不能及时释放资源
|
||||||
_ = DeletePid(Tea.Root + "/bin/pid")
|
_ = DeletePid(Tea.Root + "/bin/pid")
|
||||||
|
|||||||
@@ -10,9 +10,12 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AdminNode struct {
|
type AdminNode struct {
|
||||||
|
subPIDs []int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAdminNode() *AdminNode {
|
func NewAdminNode() *AdminNode {
|
||||||
@@ -21,12 +24,7 @@ func NewAdminNode() *AdminNode {
|
|||||||
|
|
||||||
func (this *AdminNode) Run() {
|
func (this *AdminNode) Run() {
|
||||||
// 启动管理界面
|
// 启动管理界面
|
||||||
secret := rands.String(32)
|
secret := this.genSecret()
|
||||||
|
|
||||||
// 测试环境下设置一个固定的key,方便我们调试
|
|
||||||
if Tea.IsTesting() {
|
|
||||||
secret = "8f983f4d69b83aaa0d74b21a212f6967"
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查server配置
|
// 检查server配置
|
||||||
err := this.checkServer()
|
err := this.checkServer()
|
||||||
@@ -34,6 +32,21 @@ func (this *AdminNode) Run() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 监听信号
|
||||||
|
sigQueue := make(chan os.Signal)
|
||||||
|
signal.Notify(sigQueue, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL, syscall.SIGQUIT)
|
||||||
|
go func() {
|
||||||
|
for range sigQueue {
|
||||||
|
for _, pid := range this.subPIDs {
|
||||||
|
p, err := os.FindProcess(pid)
|
||||||
|
if err == nil && p != nil {
|
||||||
|
_ = p.Kill()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// 启动API节点
|
// 启动API节点
|
||||||
this.startAPINode()
|
this.startAPINode()
|
||||||
|
|
||||||
@@ -91,13 +104,28 @@ https:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 启动API节点
|
// 启动API节点
|
||||||
func (this AdminNode) startAPINode() {
|
func (this *AdminNode) startAPINode() {
|
||||||
_, err := os.Stat(Tea.Root + "/edge-api/configs/api.yaml")
|
_, err := os.Stat(Tea.Root + "/edge-api/configs/api.yaml")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
logs.Println("start edge-api")
|
logs.Println("start edge-api")
|
||||||
err = exec.Command(Tea.Root + "/edge-api/bin/edge-api").Start()
|
cmd := exec.Command(Tea.Root + "/edge-api/bin/edge-api")
|
||||||
|
err = cmd.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Println("[ERROR]start edge-api failed: " + err.Error())
|
logs.Println("[ERROR]start edge-api failed: " + err.Error())
|
||||||
|
} else {
|
||||||
|
this.subPIDs = append(this.subPIDs, cmd.Process.Pid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 生成Secret
|
||||||
|
func (this *AdminNode) genSecret() string {
|
||||||
|
tmpFile := os.TempDir() + "/edge-secret.tmp"
|
||||||
|
data, err := ioutil.ReadFile(tmpFile)
|
||||||
|
if err == nil && len(data) == 32 {
|
||||||
|
return string(data)
|
||||||
|
}
|
||||||
|
secret := rands.String(32)
|
||||||
|
_ = ioutil.WriteFile(tmpFile, []byte(secret), 0666)
|
||||||
|
return secret
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
<a href="" class="item" @click.prevent="createPolicy()">[创建]</a>
|
<a href="" class="item" @click.prevent="createPolicy()">[创建]</a>
|
||||||
</second-menu>
|
</second-menu>
|
||||||
|
|
||||||
<p class="comment" v-if="cachePolicies.length == 0">暂时还没有缓存策略。</p>
|
<p class="comment" v-if="cachePolicies == null || cachePolicies.length == 0">暂时还没有缓存策略。</p>
|
||||||
<table class="ui table selectable" v-if="cachePolicies.length > 0">
|
<table class="ui table selectable" v-if="cachePolicies != null && cachePolicies.length > 0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>策略名称</th>
|
<th>策略名称</th>
|
||||||
|
|||||||
Reference in New Issue
Block a user