Scheduling the loading of JSON config from external URL

Not so much help needed so this may need to be moved but I have been changing my Caddy server to load its configuration from a remote URL on start up.

All worked well so decided to look pulling the config from the external server on a scheduled basis.

Nothing in the documentation but did find a few GitHub requests and found:

"config": {
    "load_interval": "60s",
    "load": {
        "module": "http",
        "timeout": "10s",
        "url": "http://localhost:5000/caddy-config"
    }
}

Looked further and found that it has been changed to “load_delay” in another GitHub commit.

Might be worth updating the documentation with this great feature.

1 Like

You’re right, it’s missing from https://caddyserver.com/docs/json/admin/config/ :thinking: we’ll look into it

1 Like

Cool.

While I have you Francis, is there a way to know if the pulling of the config failed for any reason?

We’ve moved from pushing the changes from our backend to Caddy to having Caddy pull the changes as we’re going to move to have multiple instances of Caddy and seemed like a better solution.

My only concern was that if one of the Caddy instances failed to pull the configuration from the external source it wouldn’t try again as its a one-off (delay) rather than a scheduled interval?

Found the ability to restart services here which I will look into:

If the pulled config fails to load, there will be a log emitted with the error.

The HTTP config loader/puller thingie will already perform retries in the case of network or HTTP errors, for a single tick of the timer.

1 Like

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