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

build in debain,and run in centos 7,the erroy msg is very strange. #2908

Closed
JsonSong89 opened this issue Aug 28, 2023 · 11 comments
Closed

build in debain,and run in centos 7,the erroy msg is very strange. #2908

JsonSong89 opened this issue Aug 28, 2023 · 11 comments
Labels

Comments

@JsonSong89
Copy link

1. What version of Go and system type/arch are you using?


root@pve:/work/gf-demo-user# go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.7"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/work/gf-demo-user/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3772628711=/tmp/go-build -gno-record-gcc-switches"

2. What version of GoFrame are you using?

v2.3.3

3. Can this issue be re-produced with the latest release?

debain

gcc --version
#gcc (Debian 10.2.1-6) 10.2.1 20210110
git clone https://github.com/gogf/gf-demo-user.git
go build 

centos

gcc --version
#gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)

scp   [email protected]:/work/gf-demo-user/gf-demo-deb /work/tmp/gf-demo-deb 
./gf-demo-deb
2023-08-28 17:04:40.693 [FATA] duplicated route registry "ALL:/user/profile" at /work/gf-demo-user/internal/cmd/cmd.go:38 , already registered at /work/gf-demo-user/internal/cmd/cmd.go:32
Stack:
1.  github.com/gogf/gf/v2/net/ghttp.(*Server).setHandler
   /root/go/pkg/mod/github.com/gogf/gf/[email protected]/net/ghttp/ghttp_server_router.go:139
2.  github.com/gogf/gf/v2/net/ghttp.(*Server).doBindHandler
   /root/go/pkg/mod/github.com/gogf/gf/[email protected]/net/ghttp/ghttp_server_service_handler.go:53
3.  github.com/gogf/gf/v2/net/ghttp.(*RouterGroup).doBindRoutersToServer

5. What did you expect to see?

centos run fine or show the root cause error msg

I notice the gcc version has big diff? is there the reason?
but why centOS can run the build file ?

@JsonSong89 JsonSong89 changed the title build in debain,and run in centos 7,the erroy msg is very strange: build in debain,and run in centos 7,the erroy msg is very strange. Aug 28, 2023
@JsonSong89
Copy link
Author

build in debain 11 and run in debain 10 is also same erroy
debain 10 is aliyun fc(serverless) max debian environment, so I must use debain 10 to build my app?

@JsonSong89
Copy link
Author

I remove the router code : s.Group("/"
and only have two simple handle

	s.BindHandler("/", func(r *ghttp.Request) {
		r.Response.Write("哈喽世界!")
	})
	s.BindHandler("/ip", func(r *ghttp.Request) {
		_, hip := util.GetIpFromRequest(r)
		r.Response.Write(hip)
	})

it works

so looks like this is goframe problem?

@hailaz
Copy link
Member

hailaz commented Aug 29, 2023

server.routeOverWrite

// RouteOverWrite allows to overwrite the route if duplicated.

https://goframe.org/pages/viewpage.action?pageId=44449486

@JsonSong89
Copy link
Author

the key is : if I build in debain and run in same ecs,everything is ok .

@hailaz
Copy link
Member

hailaz commented Aug 29, 2023

那么你尝试一下,在你说的系统中构建,然后放到其它任意不相关的目录执行试试,不要复制配置文件。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Then you try it, build it in the system you mentioned, and then put it in any other unrelated directory to try it out, don't copy the configuration file.

@hailaz
Copy link
Member

hailaz commented Aug 29, 2023

单从你所展示的报错来看,和配置server.routeOverWrite的相关性极大。
https://github.com/gogf/gf-demo-user/blob/master/manifest/config/config.yaml#L5

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Judging from the error report you have shown, it is very related to configuring server.routeOverWrite.
https://github.com/gogf/gf-demo-user/blob/master/manifest/config/config.yaml#L5

@JsonSong89
Copy link
Author

git clone https://github.com/gogf/gf-demo-user.git

我是直接git clone https://github.com/gogf/gf-demo-user.git编译的 一行代码都没修改
但是本地一直是可以运行,换了机器就不行,所以我一直以为是环境的问题
看了文档,我发现启动信息里面是有点不对劲
image
但确实是可以运行啊
移动到本机的其他地方也可以运行

@gqcn
Copy link
Member

gqcn commented Oct 9, 2023

@JsonSong89 Go的特性之一就是跨平台性,交叉编译,debian和centos都是属于linux平台,只要保证architecture编译架构是一致的就可以运行。你的报错是配置问题,路由覆盖问题,官方的配置文件会有一个路由覆盖的配置,主要母的是可以在中间中使用接口鉴权。

@gqcn gqcn added the question label Oct 9, 2023
@gqcn gqcn closed this as completed Oct 9, 2023
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@JsonSong89 One of the features of Go is cross-platform and cross-compilation. Both debian and centos belong to the Linux platform. As long as the architecture compilation structure is consistent, it can run. Your error is a configuration issue and a routing coverage issue. The official configuration file will have a routing coverage configuration. The main reason is that interface authentication can be used in the middle.

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

No branches or pull requests

4 participants