release: v0.2.0
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.
This commit is contained in:
2026-03-24 16:07:22 +08:00
parent 3525a59976
commit 3be3e19e49
10 changed files with 243 additions and 237 deletions

View File

@@ -3,10 +3,11 @@ package daemon
import (
"context"
"github.com/kardianos/service"
"smart-shutdown/pkg/config"
"smart-shutdown/pkg/logger"
"smart-shutdown/pkg/monitor"
"github.com/kardianos/service"
)
type program struct {
@@ -16,8 +17,7 @@ type program struct {
}
func (p *program) Start(s service.Service) error {
// Start should not block. Do the actual work async.
logger.Info("准备在后台启动服务监控...")
logger.Info("启动系统监控后台服务")
ctx, cancel := context.WithCancel(context.Background())
p.cancel = cancel
@@ -28,14 +28,12 @@ func (p *program) Start(s service.Service) error {
}
func (p *program) run(ctx context.Context) {
// 挂载执行核心循环逻辑
monitor.Run(ctx, p.cfg)
close(p.exit)
}
func (p *program) Stop(s service.Service) error {
// Stop should not block. Return within a few seconds.
logger.Info("正在平滑停止后台服务监控...")
logger.Info("停止系统监控后台服务")
if p.cancel != nil {
p.cancel()
}
@@ -43,12 +41,11 @@ func (p *program) Stop(s service.Service) error {
return nil
}
// GetService 构建 service 实例供 CLI 控制(安装,启动,停止,卸载)和前台直接 Run。
func GetService(cfg *config.Config) (service.Service, error) {
svcConfig := &service.Config{
Name: "SmartNetworkMonitor",
DisplayName: "Smart Network Shutdown Monitor",
Description: "A daemon that pings target IP periodically and shuts down the computer if disconnected for too long.",
Description: "A reliable daemon that periodically monitors network states and triggers node suspension logically.",
}
prg := &program{