@@ -7,9 +7,16 @@ import (
77 "os"
88 "path/filepath"
99
10+ "github.com/rs/zerolog/log"
1011 "github.com/threefoldtech/zos/pkg/zinit"
1112)
1213
14+ func (g * ZosAPI ) adminRebootHandler (ctx context.Context , payload []byte ) (interface {}, error ) {
15+ zinit := zinit .Default ()
16+
17+ return nil , zinit .Reboot ()
18+ }
19+
1320func (g * ZosAPI ) adminRestartServiceHandler (ctx context.Context , payload []byte ) (interface {}, error ) {
1421 var service string
1522 if err := json .Unmarshal (payload , & service ); err != nil {
@@ -21,12 +28,6 @@ func (g *ZosAPI) adminRestartServiceHandler(ctx context.Context, payload []byte)
2128 return nil , zinit .Restart (service )
2229}
2330
24- func (g * ZosAPI ) adminRebootHandler (ctx context.Context , payload []byte ) (interface {}, error ) {
25- zinit := zinit .Default ()
26-
27- return nil , zinit .Reboot ()
28- }
29-
3031func (g * ZosAPI ) adminRestartAllHandler (ctx context.Context , payload []byte ) (interface {}, error ) {
3132 zinit := zinit .Default ()
3233
@@ -35,9 +36,10 @@ func (g *ZosAPI) adminRestartAllHandler(ctx context.Context, payload []byte) (in
3536 return nil , fmt .Errorf ("failed to list node services, expecting string: %w" , err )
3637 }
3738
38- for _ , service := range services {
39- if err := zinit .Restart (service .String ()); err != nil {
40- return nil , fmt .Errorf ("failed to reboot service %s, expecting string: %w" , service .String (), err )
39+ for service := range services {
40+ log .Debug ().Str ("service" , service ).Send ()
41+ if err := zinit .Restart (service ); err != nil {
42+ return nil , fmt .Errorf ("failed to reboot service %s, expecting string: %w" , service , err )
4143 }
4244 }
4345
0 commit comments