-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
63 lines (52 loc) · 1.27 KB
/
main.go
File metadata and controls
63 lines (52 loc) · 1.27 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
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"context"
"os"
"os/signal"
"syscall"
"rshub/product/rsapp/selfdata/prowork"
"github.com/jpillora/overseer"
)
var BuildID string
var DebugCode string
var signalChannel = make(chan os.Signal)
func main() {
// ready()
overseer.Run(overseer.Config{
Required: false,
Program: prog,
Debug: false, //display log of overseer actions
Address: ":5001",
NoWarn: true,
NoRestart: true,
NoRestartAfterFetch: true,
Fetcher: prowork.GetFetcher(),
PreUpgrade: prowork.GetPreUpgrade(),
})
}
func ready() {
box := initRice()
prowork.Init(box, BuildID, DebugCode, func() {
//signalChannel <- syscall.SIGQUIT
os.Exit(0)
})
}
func prog(state overseer.State) {
ctx, cancel := context.WithCancel(context.Background())
//box := initRice()
//prowork.Init(box, BuildID, DebugCode, func() {
// //signalChannel <- syscall.SIGQUIT
// os.Exit(0)
//})
ready()
go prowork.Run(ctx)
runForSignal(func(o os.Signal) {
cancel()
})
}
func runForSignal(fExit func(os.Signal)) os.Signal {
signal.Notify(signalChannel, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT) //, syscall.SIGUSR1, syscall.SIGUSR2)
sig := <-signalChannel
fExit(sig)
return sig
}