cmd control status + expose DaemonStatus via control API

refs #10
This commit is contained in:
Christian Schwarz
2017-12-24 15:35:12 +01:00
parent 8c7e373049
commit 14b8d69a63
4 changed files with 137 additions and 2 deletions

View File

@ -55,7 +55,8 @@ func doDaemon(cmd *cobra.Command, args []string) {
type contextKey string
const (
contextKeyLog contextKey = contextKey("log")
contextKeyLog contextKey = contextKey("log")
contextKeyDaemon contextKey = contextKey("daemon")
)
type Daemon struct {
@ -74,6 +75,7 @@ func (d *Daemon) Loop(ctx context.Context) {
log := ctx.Value(contextKeyLog).(Logger)
ctx, cancel := context.WithCancel(ctx)
ctx = context.WithValue(ctx, contextKeyDaemon, d)
sigChan := make(chan os.Signal, 1)
finishs := make(chan Job)