Example #1
0
File: exit.go Project: jteso/alone
// Exit causes the virtual machine to exit. Do not run outside an
// alone app. Exit never returns to the caller.
func Exit() {
	var err error
	err = syscall.Reboot(syscall.LINUX_REBOOT_CMD_POWER_OFF)
	if err != nil {
		log.Printf("power off failed: %v", err)
	}
	err = syscall.Reboot(syscall.LINUX_REBOOT_CMD_HALT)
	if err != nil {
		log.Printf("halt failed: %v", err)
	}
	os.Exit(1)
	select {}
}
Example #2
0
// exit cleanly shuts down the system
func halt() {
	log.Infof("Powering off the system")
	if strings.HasSuffix(os.Args[0], "-debug") {
		log.Info("Squashing power off for debug tether")
		return
	}

	syscall.Sync()
	syscall.Reboot(syscall.LINUX_REBOOT_CMD_POWER_OFF)
}
Example #3
0
func reboot() {
	log.Infof("Rebooting the system")
	if strings.HasSuffix(os.Args[0], "-debug") {
		log.Info("Squashing reboot for debug init")
		return
	}

	syscall.Sync()
	syscall.Reboot(syscall.LINUX_REBOOT_CMD_RESTART)
}
Example #4
0
func reboot() {
	log.Infof("Rebooting the system")
	if debugLevel > 0 {
		log.Info("Squashing reboot for debug init")
		return
	}

	syscall.Sync()
	syscall.Reboot(syscall.LINUX_REBOOT_CMD_RESTART)
}
Example #5
0
// exit cleanly shuts down the system
func halt() {
	log.Infof("Powering off the system")
	if debugLevel > 0 {
		log.Info("Squashing power off for debug init")
		return
	}

	syscall.Sync()
	syscall.Reboot(syscall.LINUX_REBOOT_CMD_POWER_OFF)
}
Example #6
0
func main() {
	flag.Usage = usage
	flag.Parse()
	if flag.NArg() != 0 || (*hflag && *sflag) {
		usage()
	}

	cmd := syscall.LINUX_REBOOT_CMD_CAD_OFF
	if *hflag {
		cmd = syscall.LINUX_REBOOT_CMD_CAD_ON
	}
	ck(syscall.Reboot(cmd))
}
Example #7
0
func reboot(code int) {
	err := shutDownContainers()
	if err != nil {
		log.Error(err)
	}

	syscall.Sync()

	err = syscall.Reboot(code)
	if err != nil {
		log.Fatal(err)
	}
}
Example #8
0
func main() {
	flag.Usage = usage
	flag.Parse()
	if flag.NArg() != 0 {
		usage()
	}

	syscall.Sync()

	if *pflag && *rflag {
		usage()
	}

	cmd := syscall.LINUX_REBOOT_CMD_HALT
	if *pflag {
		cmd = syscall.LINUX_REBOOT_CMD_POWER_OFF
	}
	if *rflag {
		cmd = syscall.LINUX_REBOOT_CMD_RESTART
	}

	ck(syscall.Reboot(cmd))
}
func doReboot() {
	syscall.Sync()
	syscall.Reboot(syscall.LINUX_REBOOT_CMD_RESTART)
}
Example #10
0
func handleShutdownRequest(w http.ResponseWriter, r *http.Request) {
	syscall.Sync()
	syscall.Reboot(syscall.LINUX_REBOOT_CMD_POWER_OFF)
}
Example #11
0
func handleRebootRequest(w http.ResponseWriter, r *http.Request) {
	syscall.Sync()
	syscall.Reboot(syscall.LINUX_REBOOT_CMD_RESTART)
}