Provide one or more external net.Listener references

1. My Caddy version (caddy version):


2. How I run Caddy:

I run caddy with something like this:

func defaultLoader(serverType string) (caddy.Input, error) {
	contents := getCaddyFile(caddyConfig)
	return caddy.CaddyfileInput{
		Contents:       []byte(contents),
		Filepath:       caddy.DefaultConfigFile,
		ServerTypeName: serverType,
	}, nil

func StartCaddy() {
       caddy.SetDefaultCaddyfileLoader("default", caddy.LoaderFunc(defaultLoader))
       caddyfile, _ := caddy.LoadCaddyfile("http")

a. System environment:

linux, darwin

3. The problem I’m having:

I would like to specify an external net.Listener reference that caddy can start with.

Naturally, the net.Listener should match the one specified in the caddy file.

The use case is: I’m trying to use overseer, which is a self-updater for go binaries, also with zero-downtime for TCP/UDP services. Thus, I would need to create net.Listener references (or something like this) out of Caddy.

Is that possible, somehow, with the current version?
If not, is this something achievable with the current Caddy architecture? (meaning that, maybe, it could be implemented in v2?!)

Hi there, welcome!

Off the top of my head, I don’t think this is feasible: Caddy has to manage the listeners to facilitate graceful reloads and config changes.

We might be able to make this possible in Caddy 2, but I’m not sure if it’s a good idea. Someone would have to hack together a PoC and show how much API surface would have to be exported and then we’d have to think about the consequences. You’re welcome to do this, just no guarantee on timeline.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.