Some checks failed
Release / Build & Release (push) Has been cancelled
Comprehensive release containing structural, UX, and behavioral upgrades since v0.1.0: 1. Namespace Transition: Renamed core executable and project namespaces from 'smart-monitor' to 'smart-shutdown'. 2. Objective Vocabulary Refactoring: Normalized output strings and logging descriptors system-wide to a strict, professional tone. 3. Advanced Status Query: 'status' subcommand now retrieves the parsed configuration, log locations/sizes, and tails the last 10 lines of the local log file. 4. Runtime Configuration Setter: Introduced 'config set' subcommand to modify the configuration file with strict type validations. 5. Auto-System Deployment: Remapped 'install' to clone the executable into system domains and register global PATH variables. 6. Cleaner Removal: 'uninstall' purges binary clones and clears environmental variables, leaving zero traces. 7. Documentation Rewrite: Generated an objective README file featuring copy-paste ready Markdown blocks.
27 lines
453 B
Go
27 lines
453 B
Go
package system
|
|
|
|
import (
|
|
"os/exec"
|
|
"runtime"
|
|
"smart-shutdown/pkg/logger"
|
|
)
|
|
|
|
func ExecuteShutdown() error {
|
|
logger.Crit("系统调用:执行关机指令")
|
|
|
|
var cmd *exec.Cmd
|
|
if runtime.GOOS == "windows" {
|
|
cmd = exec.Command("shutdown", "-s", "-f", "-t", "0")
|
|
} else {
|
|
cmd = exec.Command("shutdown", "-h", "now")
|
|
}
|
|
|
|
err := cmd.Run()
|
|
if err != nil {
|
|
logger.Crit("系统关机指令执行失败: %v", err)
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|