-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.go
More file actions
51 lines (40 loc) · 1.01 KB
/
app.go
File metadata and controls
51 lines (40 loc) · 1.01 KB
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
package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
"runtime"
"syscall"
"github.com/etcdpad/etcdpad-core/engine"
)
func main() {
var (
port int
logpath string
defaultpath string
stdout bool
)
dir, err := os.Getwd()
if err != nil {
log.Fatal(err)
}
if runtime.GOOS == "windows" {
defaultpath = fmt.Sprintf("%s\\%s", dir, "oplog.log")
} else {
defaultpath = fmt.Sprintf("%s/%s", dir, "oplog.log")
}
flag.IntVar(&port, "port", 8989, "websocket listen port")
flag.StringVar(&logpath, "logpath", defaultpath, "websocket client operate log file directory")
flag.BoolVar(&stdout, "stdout", true, "epad log output to stdout")
flag.Parse()
log.Printf("epad log filepath: %s\n", logpath)
log.Printf("epad websocket port: %d\n", port)
log.Printf("epad log output to stdout: %+v\n", stdout)
eg := engine.NewEngine(port, logpath, stdout)
signals := make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM, syscall.SIGKILL)
<-signals
eg.ShutDown()
}