forked from dagu-org/dagu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
40 lines (34 loc) · 789 Bytes
/
server.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
package main
import (
"os"
"path"
"github.com/urfave/cli/v2"
"github.com/yohamta/dagu/internal/admin"
"github.com/yohamta/dagu/internal/utils"
)
func newServerCommand() *cli.Command {
l := &admin.Loader{}
return &cli.Command{
Name: "server",
Usage: "dagu server",
Action: func(c *cli.Context) error {
cfg, err := l.LoadAdminConfig(
path.Join(utils.MustGetUserHomeDir(), ".dagu/admin.yaml"))
if err == admin.ErrConfigNotFound {
cfg = admin.DefaultConfig()
} else if err != nil {
return err
}
return startServer(cfg)
},
}
}
func startServer(cfg *admin.Config) error {
server := admin.NewServer(cfg)
listenSignals(func(sig os.Signal) {
server.Shutdown()
})
err := server.Serve()
utils.LogIgnoreErr("running server", err)
return err
}