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

Feature request: graceful degradation when network log writer is unavailable #5520

Closed
dtelyukh opened this issue May 4, 2023 · 4 comments
Closed
Labels
discussion 💬 The right solution needs to be found feature ⚙️ New feature or request
Milestone

Comments

@dtelyukh
Copy link
Contributor

dtelyukh commented May 4, 2023

If network writer is unavailable, Caddy fails on start:

2023/05/04 15:52:32.809	INFO	using provided configuration	{"config_file": "Caddyfile", "config_adapter": ""}
Error: loading initial config: loading new config: setting up custom log 'reverse_proxy': opening log writer using &logging.NetWriter{Address:"localhost:8888", DialTimeout:1000000000, addr:caddy.NetworkAddress{Network:"tcp", Host:"localhost", StartPort:0x22b8, EndPort:0x22b8}}: dial tcp [::1]:8888: connect: connection refused

It would be better if it could start without network logger, than to fail.

@mholt
Copy link
Member

mholt commented May 4, 2023

Hm 🤔

Starting without logging -- knowingly -- sounds like a bad idea. Why would you want that?

@dtelyukh
Copy link
Contributor Author

dtelyukh commented May 4, 2023

If a remote collector is down, I want to start Caddy anyway. I can see these logs in console. And I want to have working instance of Caddy while I will fix collector.
I think remote log collector could not be required dependency. In addition, when Caddy is already run and a collector is stopped, Caddy has not any fatal error and works in normal mode.

@mholt
Copy link
Member

mholt commented May 4, 2023

There's a big difference between starting a server knowing that something is broken, and keeping a running server running -- we do the latter at all costs, but the former, still seems like a bad idea to me. But I do understand how a remote dependency is not an ideal blocker for a web server. In v2 we eased up on requiring certificates to succeed before running (granted, if you try to access your site before Caddy can get a cert, you'll get an error) -- so maybe we can do something similar for logs...

@mholt mholt added the discussion 💬 The right solution needs to be found label May 4, 2023
@mholt mholt closed this as completed in f3e8b9d May 4, 2023
@mholt
Copy link
Member

mholt commented May 4, 2023

@dtelyukh I've implemented this in f3e8b9d, and follow-up commit cdce452.

I don't feel like it's a good default to ignore log errors since I bet many users rely on it, but we can change this later probably if it turns out to be the preferred default.

Simply add the soft_start parameter to your net config in the Caddyfile:

{
	log default {
		output net foobar {
			soft_start
		}
	}
}

Or in the JSON, set soft_start to true.

@mholt mholt added the feature ⚙️ New feature or request label May 4, 2023
@mholt mholt added this to the v2.7.0 milestone May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion 💬 The right solution needs to be found feature ⚙️ New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants