parent
71326a0e19
commit
8187d3a66d
|
|
@ -15,13 +15,13 @@ build: build-server build-client
|
|||
# 编译服务器
|
||||
build-server:
|
||||
@echo "编译服务器..."
|
||||
go build -o ../bin/server ./server
|
||||
go build -ldflags "-s -w" -o ../bin/server ./server
|
||||
@echo "服务器编译完成: bin/server"
|
||||
|
||||
# 编译客户端
|
||||
build-client:
|
||||
@echo "编译客户端..."
|
||||
go build -o ../bin/client ./client
|
||||
go build -ldflags "-s -w" -o ../bin/client ./client
|
||||
@echo "客户端编译完成: bin/client"
|
||||
|
||||
# 运行服务器
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"log"
|
||||
_ "net/http/pprof" // 导入pprof用于性能分析
|
||||
"os"
|
||||
"os/signal"
|
||||
"port-forward/client/tunnel"
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"log"
|
||||
_ "net/http/pprof" // 导入pprof用于性能分析
|
||||
"os"
|
||||
"os/signal"
|
||||
"port-forward/server/api"
|
||||
|
|
@ -14,7 +12,6 @@ import (
|
|||
"port-forward/server/tunnel"
|
||||
"port-forward/server/utils"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -146,13 +143,9 @@ func main() {
|
|||
log.Println("\n接收到关闭信号,正在优雅关闭...")
|
||||
|
||||
// 创建关闭上下文
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
// 停止所有转发器
|
||||
log.Println("停止所有端口转发...")
|
||||
fwdManager.StopAll()
|
||||
|
||||
log.Println("服务器已关闭")
|
||||
<-ctx.Done()
|
||||
}
|
||||
Loading…
Reference in New Issue