forked from alireza0/s-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
49 lines (41 loc) · 612 Bytes
/
main.go
File metadata and controls
49 lines (41 loc) · 612 Bytes
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
package main
import (
"log"
"os"
"os/signal"
"syscall"
"github.com/alireza0/s-ui/app"
"github.com/alireza0/s-ui/cmd"
)
func runApp() {
app := app.NewApp()
err := app.Init()
if err != nil {
log.Fatal(err)
}
err = app.Start()
if err != nil {
log.Fatal(err)
}
sigCh := make(chan os.Signal, 1)
// Trap shutdown signals
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGTERM)
for {
sig := <-sigCh
switch sig {
case syscall.SIGHUP:
app.RestartApp()
default:
app.Stop()
return
}
}
}
func main() {
if len(os.Args) < 2 {
runApp()
return
} else {
cmd.ParseCmd()
}
}