Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
Change reboot error messages and timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Feb 23, 2015
1 parent db94dfa commit e5192dd
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions cmd/power/power.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,23 @@ const (

func PowerOff() {
if os.Geteuid() != 0 {
log.Info("poweroff: Permission Denied")
return
log.Fatalf("%s: Permission Denied", os.Args[0])
}
syscall.Sync()
reboot(syscall.LINUX_REBOOT_CMD_POWER_OFF)
}

func Reboot() {
if os.Geteuid() != 0 {
log.Info("reboot: Permission Denied")
return
log.Fatalf("%s: Permission Denied", os.Args[0])
}
syscall.Sync()
reboot(syscall.LINUX_REBOOT_CMD_RESTART)
}

func Halt() {
if os.Geteuid() != 0 {
log.Info("reboot: Permission Denied")
return
log.Fatalf("%s: Permission Denied", os.Args[0])
}
syscall.Sync()
reboot(syscall.LINUX_REBOOT_CMD_HALT)
Expand All @@ -47,7 +44,7 @@ func Halt() {
func reboot(code int) {
err := shutDownContainers()
if err != nil {
log.Fatal(err)
log.Error(err)
}
err = syscall.Reboot(code)
if err != nil {
Expand All @@ -58,7 +55,7 @@ func reboot(code int) {
func shutDownContainers() error {
var err error
shutDown := true
timeout := uint(0)
timeout := uint(2)
for i := range os.Args {
arg := os.Args[i]
if arg == "-f" || arg == "--f" || arg == "--force" {
Expand Down

0 comments on commit e5192dd

Please sign in to comment.