Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

服务进程杀死后,再启动提示端口被占用 #1212

Closed
jinkaz opened this issue Oct 15, 2024 · 12 comments
Closed

服务进程杀死后,再启动提示端口被占用 #1212

jinkaz opened this issue Oct 15, 2024 · 12 comments
Labels

Comments

@jinkaz
Copy link

jinkaz commented Oct 15, 2024

服务进程通过kill-2 kill-9 关停后,重新通过nohup ./xxx & 提示端口号被占用

日志:panic: create netpoll listener fail: listen tcp 0.0.0.0:8523: bind: address already in use
-2 也看到了优雅停机的日志:
2024/10/14 17:45:08.359425 hertz.go:113: [Info] HERTZ: Received signal: interrupt
2024/10/14 17:45:08.359502 hertz.go:77: [Info] HERTZ: Begin graceful shutdown, wait at most num=5 seconds...
2024/10/14 17:45:08.361387 registry.go:121: [Info] HERTZ: deregister instance success
2024/10/14 17:45:08.361504 engine.go:314: [Info] HERTZ: Execute OnShutdownHooks finish

能否麻烦看看如何能正常重启服务

hertz版本:0.9.3

服务器环境:Ubuntu 22.04.3 LTS

set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\jim\AppData\Local\go-build
set GOENV=C:\Users\jim\AppData\Roaming\go\env
set GOEXE=
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\jim\go_workplace\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=linux
set GOPATH=C:\jim\go_workplace;C:\Users\jim\go
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=C:/jim/dev_file/go/1.23.1
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\jim\dev_file\go\1.23.1\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.23.1
set GODEBUG=
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\jim\AppData\Roaming\go\telemetry
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=C:\jim\work_place\ea\zang-purchase-complaint\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\jim\AppData\Local\Temp\go-build2843335204=/tmp/go-build -gno-record-gcc-switches

整体是在windows机器上执行go build -ldflags '-w -s -X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn'打包
二进制复制到测试服务器上执行启动

@github-actions github-actions bot added the invalid issue invalid issue (not related to Hertz or described in document or not enough information provided) label Oct 15, 2024
Copy link

This issue has been marked as invalid question, please give more information by following the issue template. The issue will be closed in 1 days if no further activity occurs.

@github-actions github-actions bot added the stale label Oct 15, 2024
@rogerogers
Copy link
Contributor

rogerogers commented Oct 15, 2024

Windows 有 kill -9

@jinkaz
Copy link
Author

jinkaz commented Oct 15, 2024

Windows 有 kill -9

编译在windows,执行在Ubuntu。

@rogerogers
Copy link
Contributor

sudo netstat -lntp | grep 8523 找到进程号,然后 kill 掉就好了,kill -9 强制关闭进程可能会有端口没释放的情况

@GuangmingLuo GuangmingLuo removed the invalid issue invalid issue (not related to Hertz or described in document or not enough information provided) label Oct 15, 2024
@jinkaz
Copy link
Author

jinkaz commented Oct 15, 2024

sudo netstat -lntp | grep 8523 找到进程号,然后 kill 掉就好了,kill -9 强制关闭进程可能会有端口没释放的情况

试了下,看日志提示
HERTZ: Receive close signal: error=terminated
HERTZ: Close error=context deadline exceeded
重新启动还是提示create netpoll listener fail: listen tcp 0.0.0.0:8523: bind: address already in use

@rogerogers
Copy link
Contributor

不是只执行就 OK 了,执行完要看下是否还有进程在,方便的话可以放一下执行前后的截图

@jinkaz
Copy link
Author

jinkaz commented Oct 15, 2024

不是只执行就 OK 了,执行完要看下是否还有进程在,方便的话可以放一下执行前后的截图

1
2

@jinkaz
Copy link
Author

jinkaz commented Oct 15, 2024

不是只执行就 OK 了,执行完要看下是否还有进程在,方便的话可以放一下执行前后的截图

这是正好可以执行的情况,这是整个我操作的,一个是操作截图,一个是日志截图。您看是不是哪里有问题

@rogerogers
Copy link
Contributor

netstat 之后是 kill -9,nohup 是忽略 kill -HUP

@jinkaz
Copy link
Author

jinkaz commented Oct 15, 2024

还是不行

@jinkaz
Copy link
Author

jinkaz commented Oct 16, 2024

已解决了

@jinkaz jinkaz closed this as completed Oct 16, 2024
@rogerogers
Copy link
Contributor

有用的经验,方便的话可以分享下哦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants