Esempio n. 1
0
File: exit.go Progetto: 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 {}
}
Esempio n. 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)
}
Esempio n. 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)
}
Esempio n. 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)
}
Esempio n. 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)
}
Esempio n. 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))
}
Esempio n. 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)
	}
}
Esempio n. 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))
}
Esempio n. 9
0
func doReboot() {
	syscall.Sync()
	syscall.Reboot(syscall.LINUX_REBOOT_CMD_RESTART)
}
Esempio n. 10
0
func handleShutdownRequest(w http.ResponseWriter, r *http.Request) {
	syscall.Sync()
	syscall.Reboot(syscall.LINUX_REBOOT_CMD_POWER_OFF)
}
Esempio n. 11
0
func handleRebootRequest(w http.ResponseWriter, r *http.Request) {
	syscall.Sync()
	syscall.Reboot(syscall.LINUX_REBOOT_CMD_RESTART)
}