31 lines
444 B
Go
31 lines
444 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"net-tunnel/internal/server"
|
|
)
|
|
|
|
func main() {
|
|
// 创建服务端
|
|
srv := server.NewServer("0.0.0.0", 7000)
|
|
|
|
// 在后台启动服务
|
|
go func() {
|
|
if err := srv.Start(); err != nil {
|
|
log.Fatalf("Server error: %v", err)
|
|
}
|
|
}()
|
|
|
|
// 等待中断信号
|
|
sig := make(chan os.Signal, 1)
|
|
signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM)
|
|
<-sig
|
|
|
|
// 优雅关闭
|
|
srv.Stop()
|
|
}
|