-
Notifications
You must be signed in to change notification settings - Fork 2
/
redisvo.go
58 lines (54 loc) · 1.67 KB
/
redisvo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"fmt"
"net/http"
"os"
"os/signal"
"path/filepath"
"syscall"
)
func main() {
fmt.Printf("%s \n", LOGO)
dir, _ = filepath.Abs(filepath.Dir(os.Args[0]))
defer func() {
if err := recover(); err != nil {
fmt.Printf("run time panic: %v", err)
}
fmt.Printf("redisvo Exited ...\n")
}()
if err := createConfigFile(); err != nil {
fmt.Printf("create redisvo.toml error: %v", err)
}
http.HandleFunc("/login", login)
http.HandleFunc("/config", getConfigInfo)
http.HandleFunc("/monitor", redisMonitorRealTime)
http.HandleFunc("/static/", getAsset)
http.HandleFunc("/ping", ping)
http.HandleFunc("/getlist", validate(getServerList))
http.HandleFunc("/addServer", addServer)
http.HandleFunc("/server", getServerKeyNameHtml)
http.HandleFunc("/serverinfo", getInfoByServerAndDb)
http.HandleFunc("/search", getInfoBySearchKey)
http.HandleFunc("/searchfield", searchFieldByTypeName)
http.HandleFunc("/showfields", getInfoByTypeNameorKey)
http.HandleFunc("/addkey", addFieldsByTypeAndName)
http.HandleFunc("/deletekey", deleteTypeName)
http.HandleFunc("/modify", modifyTypeName)
http.HandleFunc("/changeContent", saveChangeContent)
http.HandleFunc("/terminal", execInstruction)
http.HandleFunc("/", getMainInterface)
go func(serverAddress string) {
if err := http.ListenAndServe(serverAddress, nil); err != nil {
panic("Binding service ip and port error, please check whether the port is occupied and then restart ... ")
}
}(getServerAddress())
stopSignals()
}
// stopSignals kill this programme
func stopSignals() {
chExit := make(chan os.Signal, 1)
signal.Notify(chExit, syscall.SIGINT, syscall.SIGTERM, syscall.SIGKILL)
select {
case <-chExit:
}
}