Files
frpc-client-win/internal/service/signals_windows.go
T
cnbugs 69801ecc3f Initial commit: frpc-client-win v1.0
Single-file Windows frpc service wrapper.

Features:
- Embeds frpc v0.70.1 (16.7MB) into one 18.9MB EXE
- Registers as Windows Service (auto-start, no login required)
- Auto-detects frpc config by three-tier search:
  1. frpc.ini  2. frpc.toml  3. any *.ini/*.toml in exe dir
- Self-healing supervisor: frpc crashes are restarted with
  exponential backoff (2s..60s), capped to avoid log spam
- Console subsystem so install/start show feedback
- FreeConsole on SCM start to suppress console window
- Logs to <exe-dir>/logs/service.log

Subcommands:
  install  start  stop  remove  import  -d

Smoke test (smoke_linux.go) covers all config detection paths
including the custom-name (e.g. frpc-mike.ini) use case.
2026-08-10 22:11:43 +08:00

20 lines
529 B
Go

//go:build windows
// +build windows
package service
import (
"os"
"os/signal"
)
// signalNotify 在 Windows 下注册 Ctrl+C。
//
// 注意:SCM 控制的服务不通过信号停止,而是通过 svc.ChangeRequest。
// 这个函数只对控制台前台模式(RunForeground)有意义。
// 若编译时使用了 -H windowsgui(隐藏控制台),前台模式将无法响应 Ctrl+C,
//
// 只能通过任务管理器结束进程 - 这是预期行为。
func signalNotify(ch chan<- os.Signal) {
signal.Notify(ch, os.Interrupt)
}