github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/cmd/jujud/reboot/reboot_windows.go (about)

     1  package reboot
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/juju/juju/apiserver/params"
     7  )
     8  
     9  // scheduleAction will do a reboot or shutdown after given number of seconds
    10  // this function executes the operating system's reboot binary with apropriate
    11  // parameters to schedule the reboot
    12  // If action is params.ShouldDoNothing, it will return immediately.
    13  // NOTE: On Windows the shutdown command is async
    14  func scheduleAction(action params.RebootAction, after int) error {
    15  	if action == params.ShouldDoNothing {
    16  		return nil
    17  	}
    18  	args := []string{"shutdown.exe", "-f"}
    19  	switch action {
    20  	case params.ShouldReboot:
    21  		args = append(args, "-r")
    22  	case params.ShouldShutdown:
    23  		args = append(args, "-s")
    24  	}
    25  	args = append(args, "-t", fmt.Sprintf("%d", after))
    26  
    27  	return runCommand(args)
    28  }