pydio / cells

Future-proof content collaboration platform

Home Page:https://pydio.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cells exit with 1 if 8002 port is already used

Mizuho32 opened this issue · comments

What happened

cells exit with code 1 without any print if the port 8002 is already used.

Example:

[~/prjs/pydio-cells-build/cells]
mizuho@mouse $1=>> sudo lsof -i:8002                                                           main  +11/-1 
COMMAND    PID   USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
ruby    144933 mizuho    5u  IPv4 1206500      0t0  TCP *:teradataordbms (LISTEN)
ruby    144933 mizuho    6u  IPv6 1206501      0t0  TCP *:teradataordbms (LISTEN)

[~/prjs/pydio-cells-build/cells]
mizuho@mouse $0=>> ./cells2 start                                                              main  +11/-1 

[~/prjs/pydio-cells-build/cells]
mizuho@mouse $1=>>                                                                             main  +11/-1 

Problem location

I found the cause by using delve as shown below. I'm not sure why no printing even if log.Fatal is used. Troubleshooting was pretty hard because of this.

(dlv) n
> github.com/pydio/cells/v4/cmd.startDiscoveryServer() github.com/pydio/cells/v4/cmd/start.go:311 (PC: 0x2bb2634)
   306:                 return err
   307:         }
   308:
   309:         lis, err := net.Listen("tcp", runtime.GrpcDiscoveryBindAddress())
   310:         if err != nil {
=> 311:                 log.Fatalf("failed to listen: %v", err)
   312:         }                                                                                                                                                                                                                     313:
   314:         ctx = servercontext.WithRegistry(ctx, reg)
   315:         srv := servergrpc.New(ctx, servergrpc.WithListener(lis))
   316:
(dlv) p err
error(*net.OpError) *{
        Op: "listen",
        Net: "tcp",
        Source: net.Addr nil,                                                                                                                                                                                                              Addr: net.Addr(*net.TCPAddr) *{
                IP: net.IP len: 0, cap: 0, nil,
                Port: 8002,
                Zone: "",},
        Err: error(*os.SyscallError) *{
                Syscall: "bind",
                Err: error(syscall.Errno) *(*error)(0x400206f9f0),},}
(dlv) call log.Fatalf("failed to listen: %v", err)
> github.com/pydio/cells/v4/cmd.startDiscoveryServer() github.com/pydio/cells/v4/cmd/start.go:311 (PC: 0x2bb2634)
Command failed: backend does not support function calls

Environment

I built binary both on amd64 and arm64, and for all of them I confirmed the problem happens.

The command to build cells is this. Only all=-N -l added.

mizuho@mouse $0=>> env GOOS=linux GOARCH=arm64 make main                                                   main
go build -a -trimpath\
 -gcflags "all=-N -l"\
 -ldflags "-X github.com/pydio/cells/v4/common.version=4.0.0-dev.20220423080015\
 -X github.com/pydio/cells/v4/common.BuildStamp=2022-04-23T08:00:15\
 -X github.com/pydio/cells/v4/common.BuildRevision=508304f608a997f1f877f44fdb173d557b2e7e8c"\
 -o cells\
 .
mizuho@mouse $130=>> env GOOS=linux GOARCH=amd64 make main2                                    main  +11/-1 
go build -a -trimpath\
 -gcflags "all=-N -l"\
 -ldflags "-X github.com/pydio/cells/v4/common.version=4.0.0-dev.20220423100700\
 -X github.com/pydio/cells/v4/common.BuildStamp=2022-04-23T10:07:00\
 -X github.com/pydio/cells/v4/common.BuildRevision=508304f608a997f1f877f44fdb173d557b2e7e8c"\
 -o cells2\
 .

The commit is 508304f and go version go1.16.10 linux/amd64.

Solved in main branch (postpone initLogLevel to avoid capturing StdErr too fast)