How does load_interval work?

1. Caddy version (caddy version):

v2.4.6.

2. How I run Caddy:

a. System environment:

Docker.

b. Command:

BASIC_AUTH_PASSWORD_HASHED=$(caddy hash-password --plaintext $BASIC_AUTH_PASSWORD) caddy run --config /etc/caddy/Caddyfile.json

c. Service/unit/compose file:

ARG CADDY_VERSION=2.4.6

FROM caddy:${CADDY_VERSION}-builder-alpine AS builder

ARG ROUTE53_VERSION=v1.1.2
ARG TLSREDIS_VERSION=v0.2.7
RUN xcaddy build \
    --with github.com/caddy-dns/route53@${ROUTE53_VERSION} \
    --with github.com/gamalan/caddy-tlsredis@${TLSREDIS_VERSION}

FROM caddy:${CADDY_VERSION}-alpine
COPY --from=builder /usr/bin/caddy /usr/bin/caddy

ENV XDG_DATA_HOME=/data \
    XDG_CONFIG_HOME=/config

COPY static/root /

CMD ["scaddy"]

d. My complete Caddyfile or JSON config:

{
    "admin": {
        "listen": ":2099",
        "config": {
            "load_interval": "60s",
            "load": {
                "module": "http",
                "timeout": "10s",
                "url": "http://localhost:5000/caddy-config"
            }
        }
    },
    "apps": {
        "http": {
            "servers": {
                "local": {
                    "listen": [":8080"]
                }
            }
        }
    }
}

3. The problem I’m having:

The configuration is never loaded again, after the initial load. I thought it would attempt to load configuration every 60s (based on the config).

4. Error messages and/or full log output:

{“level”:“info”,“ts”:1637042240.4107828,“msg”:“dynamically-loaded config applied successfully”}
{“level”:“info”,“ts”:1637042228.738454,“msg”:“applying dynamically-loaded config”,“loader_module”:“http”,“pull_interval”:60000000000}

5. What I already tried:

6. Links to relevant resources:

Hmm, strange. That is how it’s implemented, as far as I can tell. I’m not spotting a bug, if any :thinking:

Thoughts @matt ?

(See update below)

Oops, it needs to be wrapped in a for { } loop.

Surprised someone is using this feature. :grinning_face_with_smiling_eyes:

Should be fixed in core: Load config at interval instead of just once · caddyserver/caddy@7f364c7 · GitHub.

Awesome! Thanks. I’ve been waiting for this feature :slight_smile:

1 Like

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

After further discussion, it seems my change was an overly-hasty “non-fix”: The config loader does not behave as expected · Issue #4577 · caddyserver/caddy · GitHub

And the commit above has been reverted. I believe the dynamic config load functionality works as intended (and even better now).

1 Like