package updater import ( "sync" "forge.cadoles.com/Pyxis/golang-socketio" "github.com/pkg/errors" ) const ( eventReboot = "reboot now" ) // RebootNow asks the ReachRS module to reboot now func (c *Client) RebootNow(waitDisconnect bool) error { var err error var wg sync.WaitGroup if waitDisconnect { wg.Add(1) err = c.On(gosocketio.OnDisconnection, func(h *gosocketio.Channel) { c.Off(gosocketio.OnDisconnection) wg.Done() }) if err != nil { return errors.Wrapf(err, "error while binding to '%s' event", gosocketio.OnDisconnection) } } if err = c.Emit(eventReboot, nil); err != nil { return err } if waitDisconnect { wg.Wait() } return err }