Skip to content
This repository has been archived by the owner on Jul 18, 2020. It is now read-only.

hook.service causes panic on shutdown #25

Closed
tobya opened this issue Feb 4, 2019 · 5 comments
Closed

hook.service causes panic on shutdown #25

tobya opened this issue Feb 4, 2019 · 5 comments

Comments

@tobya
Copy link

tobya commented Feb 4, 2019

if hook.service is build into caddy using current master if caddy is run from command line in windows and then stopped by ctrl-c the following panic happens

panic: close of closed channel

goroutine 81 [running]:
github.com/mholt/caddy/vendor/github.com/mholt/certmagic.(*Cache).Stop(...)
        D:/godev/src/github.com/mholt/caddy/vendor/github.com/mholt/certmagic/cache.go:87
github.com/mholt/caddy/caddytls.NewConfig.func1(0x10694f0, 0xc0420cc340)
        D:/godev/src/github.com/mholt/caddy/caddytls/config.go:105 +0x35
github.com/mholt/caddy.(*Instance).ShutdownCallbacks(0xc04223c000, 0xc0420cc340, 0xc0420cc340, 0x0)
        D:/godev/src/github.com/mholt/caddy/caddy.go:169 +0xba
github.com/mholt/caddy.allShutdownCallbacks(0xbf02d0, 0x8, 0xad3bc0)
        D:/godev/src/github.com/mholt/caddy/sigtrap.go:100 +0x114
github.com/mholt/caddy.executeShutdownCallbacks.func1()
        D:/godev/src/github.com/mholt/caddy/sigtrap.go:80 +0x96
sync.(*Once).Do(0x1097820, 0xc042007f88)
        C:/Go/src/sync/once.go:44 +0xc5
github.com/mholt/caddy.executeShutdownCallbacks(0xbed72f, 0x6, 0x0)
        D:/godev/src/github.com/mholt/caddy/sigtrap.go:76 +0x7a
github.com/mholt/caddy.trapSignalsCrossPlatform.func1.1()
        D:/godev/src/github.com/mholt/caddy/sigtrap.go:66 +0x3d
created by github.com/mholt/caddy.trapSignalsCrossPlatform.func1
        D:/godev/src/github.com/mholt/caddy/sigtrap.go:65 +0xe3

In discussion @mholt thought perhaps

It looks like they're calling ShutdownCallbacks too, but the Ctrl+c handler does this already

@hacdias
Copy link
Owner

hacdias commented May 12, 2019

Hmm... we do call ShutdownCallbacks when stopping the service. We call that and instance.Stop. Shouldn't we?

/cc @mholt

@mholt
Copy link

mholt commented May 13, 2019

No, I don't believe so. The caddy package does that already. https://sourcegraph.com/github.com/mholt/caddy@a2ed91bc45c8b3faa1577ed4c18334d38a581ca7/-/blob/sigtrap.go#L66

@hacdias
Copy link
Owner

hacdias commented May 13, 2019

@mholt hmmm... it does that when signals are emitted. What about services shutting down? I'm not sure how they work and if there's a signal being emitted. I can try removing them and see what happens tho.

@mholt
Copy link

mholt commented May 13, 2019

Yeah... sorry, it is a little confusing in this case because of the whole service paradigm.

Some service managers like systemd send a signal to shut down the process, making these calls redundant. (I'm not sure what Windows does.)

@hacdias
Copy link
Owner

hacdias commented Jul 17, 2020

Due to the recent developments of Caddy (v2!) and the incompatibility of this plugin with newer versions, as well as not being maintained, I'm closing this issue and archiving the repository.

@hacdias hacdias closed this as completed Jul 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants