mirror of https://github.com/nocturn9x/nimd.git
Minor changes to nimDExit and shutdown.nim
This commit is contained in:
parent
c0a3c18140
commit
d240d05cef
|
@ -32,16 +32,14 @@ type ShutdownHandler* = ref object
|
||||||
|
|
||||||
|
|
||||||
const reboot_codes = {"poweroff": 0x4321fedc'i64, "reboot": 0x01234567'i64, "halt": 0xcdef0123}.toTable()
|
const reboot_codes = {"poweroff": 0x4321fedc'i64, "reboot": 0x01234567'i64, "halt": 0xcdef0123}.toTable()
|
||||||
|
var shutdownHandlers: seq[ShutdownHandler] = @[]
|
||||||
|
var sigTermDelay: float = 90
|
||||||
|
|
||||||
|
|
||||||
proc newShutdownHandler*(body: proc (logger: Logger, code: int)): ShutdownHandler =
|
proc newShutdownHandler*(body: proc (logger: Logger, code: int)): ShutdownHandler =
|
||||||
result = ShutdownHandler(body: body)
|
result = ShutdownHandler(body: body)
|
||||||
|
|
||||||
|
|
||||||
var shutdownHandlers: seq[ShutdownHandler] = @[]
|
|
||||||
var sigTermDelay: float = 90
|
|
||||||
|
|
||||||
|
|
||||||
proc setSigTermDelay*(delay: int = 90) =
|
proc setSigTermDelay*(delay: int = 90) =
|
||||||
# Sets the sigtermDelay variable
|
# Sets the sigtermDelay variable
|
||||||
sigTermDelay = float(delay)
|
sigTermDelay = float(delay)
|
||||||
|
@ -97,8 +95,8 @@ proc nimDExit*(logger: Logger, code: int, emerg: bool = true) =
|
||||||
# We're in emergency mode: do not crash the kernel, spawn a shell and exit
|
# We're in emergency mode: do not crash the kernel, spawn a shell and exit
|
||||||
logger.fatal("NimD has entered emergency mode and cannot continue. You will be now (hopefully) dropped in a root shell: you're on your own. May the force be with you")
|
logger.fatal("NimD has entered emergency mode and cannot continue. You will be now (hopefully) dropped in a root shell: you're on your own. May the force be with you")
|
||||||
logger.info("Terminating child processes with SIGKILL")
|
logger.info("Terminating child processes with SIGKILL")
|
||||||
discard execCmd(os.getEnv("SHELL", "/bin/sh")) # TODO: Is this fine? maybe use execProcess
|
|
||||||
discard posix.kill(-1, SIGKILL)
|
discard posix.kill(-1, SIGKILL)
|
||||||
|
discard execCmd(os.getEnv("SHELL", "/bin/sh")) # TODO: Is this fine? maybe use execProcess
|
||||||
quit(-1)
|
quit(-1)
|
||||||
logger.warning("The system is shutting down")
|
logger.warning("The system is shutting down")
|
||||||
logger.info("Processing shutdown runlevel")
|
logger.info("Processing shutdown runlevel")
|
||||||
|
@ -121,6 +119,7 @@ proc nimDExit*(logger: Logger, code: int, emerg: bool = true) =
|
||||||
logger.info("Terminating child processes with SIGKILL")
|
logger.info("Terminating child processes with SIGKILL")
|
||||||
discard posix.kill(-1, SIGKILL)
|
discard posix.kill(-1, SIGKILL)
|
||||||
logger.warning("Shutdown procedure complete, NimD is exiting")
|
logger.warning("Shutdown procedure complete, NimD is exiting")
|
||||||
|
quit(-1)
|
||||||
|
|
||||||
|
|
||||||
proc reboot*(logger: Logger) =
|
proc reboot*(logger: Logger) =
|
||||||
|
|
Loading…
Reference in New Issue