-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
64 lines (55 loc) · 1.21 KB
/
main.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
59
60
61
62
63
64
package main
import (
"fmt"
"os"
"os/signal"
"runtime"
"syscall"
rice "github.com/GeertJohan/go.rice"
"github.com/enify/multi-downloader/app"
"github.com/enify/multi-downloader/app/model"
)
// will be inject at building
var (
AppName = "Debug Mode"
AppVer = "0.0.0"
AppDesc = "你正处于debug模式"
)
func main() {
rice.MustFindBox("res")
meta := &model.AppMeta{
AppName: AppName,
Version: AppVer,
Description: AppDesc,
MainPage: "rice://res/App.htm",
ConfigPath: "./Config.json",
TaskStoragePath: "./TaskStorage.json",
LogPath: "./app.log",
LogLevel: "INFO",
IsDebug: AppVer == "0.0.0",
}
svr, err := app.New(meta)
if err != nil {
panic(err)
}
svr.Init()
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
go func() {
for {
s := <-c
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
msg := fmt.Sprintf("signal received:%s", s.String())
os.Exit(svr.Exit(msg))
case syscall.SIGHUP:
default:
return
}
}
}()
svr.Run()
}
func init() {
runtime.LockOSThread()
}