forked from maddevsio/openfreecab-storage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (35 loc) · 812 Bytes
/
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
package main
import (
"os"
"os/signal"
"time"
"github.com/gen1us2k/log"
"github.com/maddevsio/openfreecab-storage/conf"
"github.com/maddevsio/openfreecab-storage/service"
"github.com/urfave/cli"
)
func main() {
app := conf.NewConfigurator()
app.App().Action = func(c *cli.Context) error {
worker := service.NewOpenStorage(app.Get())
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, os.Interrupt, os.Kill)
defer signal.Stop(signalChan)
go func() {
<-signalChan
log.Info("Interrupting...")
worker.Stop()
time.Sleep(1 * time.Second)
os.Exit(0)
}()
err := worker.Start()
if err != nil {
log.Fatalf("error starting service, %v", err)
}
worker.WaitStop()
return nil
}
if err := app.Run(); err != nil {
log.Fatalf("error on run app, %v", err)
}
}