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

deadlock? #9

Closed
analytically opened this issue Oct 3, 2014 · 7 comments
Closed

deadlock? #9

analytically opened this issue Oct 3, 2014 · 7 comments

Comments

@analytically
Copy link

2014/09/29 19:27:13 Listening on 127.0.0.1:666
fatal error: all goroutines are asleep - deadlock!

goroutine 1 [IO wait]:
net.runtime_pollWait(0x7fbe378d7618, 0x72, 0x0)
        /usr/lib/go/src/pkg/runtime/netpoll.goc:116 +0x6a
net.(*pollDesc).Wait(0xc2100537d0, 0x72, 0x7fbe378d60e8, 0xb)
        /usr/lib/go/src/pkg/net/fd_poll_runtime.go:81 +0x34
net.(*pollDesc).WaitRead(0xc2100537d0, 0xb, 0x7fbe378d60e8)
        /usr/lib/go/src/pkg/net/fd_poll_runtime.go:86 +0x30
net.(*netFD).accept(0xc210053770, 0x72cd18, 0x0, 0x7fbe378d60e8, 0xb)
        /usr/lib/go/src/pkg/net/fd_unix.go:382 +0x2c2
net.(*TCPListener).AcceptTCP(0xc210000250, 0x18, 0xc21000b810, 0x44c713)
        /usr/lib/go/src/pkg/net/tcpsock_posix.go:233 +0x47
net.(*TCPListener).Accept(0xc210000250, 0x7fbe378d65f8, 0xc21001ec00, 0x0, 0x0)
        /usr/lib/go/src/pkg/net/tcpsock_posix.go:243 +0x27
net/http.(*Server).Serve(0xc21001f500, 0x7fbe378d6650, 0xc210000250, 0x0, 0x0)
        /usr/lib/go/src/pkg/net/http/server.go:1622 +0x91
net/http.(*Server).ListenAndServe(0xc21001f500, 0xc21001f500, 0x1b)
        /usr/lib/go/src/pkg/net/http/server.go:1612 +0xa0
net/http.ListenAndServe(0x7fffe4217d5c, 0xd, 0x0, 0x0, 0x1, ...)
        /usr/lib/go/src/pkg/net/http/server.go:1677 +0x6d
main.main()
        /usr/share/go/src/github.com/bketelsen/captainhook/main.go:34 +0x321
2014/09/29 19:27:13 Listening on 127.0.0.1:667
@bketelsen
Copy link
Owner

why do you have two different ports listening? Looks like 666 and 667?

@analytically
Copy link
Author

I'm running CaptainHook on Docker with autorestart=true. So to be able to run CaptainHook in multiple containers on the same machine with --net=host Docker, I use

#!/bin/bash

increment=${CAPTAINHOOK_PORT_INCREMENT:-1}
port=${CAPTAINHOOK_PORT:-666}

isfree=$(netstat -tapln | grep $port)
while [[ -n "$isfree" ]]; do
  port=$[port+increment]
  isfree=$(netstat -tapln | grep $port)
done

exec /usr/share/gocode/bin/captainhook -listen-addr 127.0.0.1:$port -configdir /etc/captainhook -echo

Hence the 2014/09/29 19:27:13 Listening on 127.0.0.1:667 line.

@analytically
Copy link
Author

So basically, I think this goes like: bind to 666, crash without releasing the bind, bind on 667.

@analytically
Copy link
Author

PS this is on Ubuntu 14.04 using Go 1.2.1.

@bketelsen
Copy link
Owner

It's deadlocked because the port is in use. Your incrementing script might have a bug?

@analytically
Copy link
Author

Hmm this is running on a machine with only one Docker container running, so the port wasn't in use. I can also see that by the 2014/09/29 19:27:13 Listening on 127.0.0.1:666 line. If the port was in use, it would not have bound to it.

@bketelsen
Copy link
Owner

it didn't bind to it, that's line 34 in your stack trace. Go is waiting for that port to be freed.

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

No branches or pull requests

2 participants