Caddy Struggles to STOP

1. Caddy version:

v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=

2. How I installed, and run Caddy:

Using Caddy official documentation

a. System environment:

Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-58-generic x86_64)

b. Command:

caddy stop

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

d. My complete Caddy config:

{
    "logging": {
        "logs": {
            "default": {
                "exclude": [
                    "http.log.access.logFiltered",
                    "http.handlers.mercure"
                ]
            },
            "logFiltered": {
                "level": "ERROR",
                "include": [
                    "http.log.access.logFiltered"
                ]
            }
        }
    },
    "apps": {
        "http": {
            "servers": {
                "srv0": {
                    "listen": [
                        ":443"
                    ],
                    "routes": [
                        {
                            "match": [
                                {
                                    "host": [
                                        "test.domainname.com"
                                    ]
                                }
                            ],
                            "handle": [
                                {
                                    "handler": "subroute",
                                    "routes": [
                                        {
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "cors_origins": [
                                                                        "https://socket.domainname.com"
                                                                    ],
                                                                    "handler": "mercure",
                                                                    "publish_origins": [
                                                                        "*"
                                                                    ],
                                                                    "publisher_jwt": {
                                                                        "key": "!ChangsseMe!"
                                                                    },
                                                                    "subscriber_jwt": {
                                                                        "key": "!ChansssgeMe!"
                                                                    },
                                                                    "transport_url": "local://local",
                                                                    "subscriptions": true,
                                                                    "write_timeout": 0
                                                                }
                                                            ]
                                                        },
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "subroute",
                                                                    "routes": [
                                                                        {
                                                                            "handle": [
                                                                                {
                                                                                    "handler": "metrics"
                                                                                }
                                                                            ]
                                                                        }
                                                                    ]
                                                                }
                                                            ],
                                                            "match": [
                                                                {
                                                                    "path": [
                                                                        "/metrics"
                                                                    ]
                                                                }
                                                            ]
                                                        },
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "static_response",
                                                                    "status_code": 200
                                                                }
                                                            ],
                                                            "match": [
                                                                {
                                                                    "path": [
                                                                        "/healthz"
                                                                    ]
                                                                }
                                                            ]
                                                        },
                                                        {
                                                            "handle": [
                                                                {
                                                                    "body": "Not Found",
                                                                    "handler": "static_response",
                                                                    "status_code": 404
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                },
                                                {
                                                    "handler": "file_server",
                                                    "hide": [
                                                        "/etc/caddy/CaddyFile.json"
                                                    ]
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ],
                            "terminal": true
                        }
                    ],
                    "logs": {
                        "logger_names": {
                            "mercure.work2.domainname.com": "logFiltered"
                        }
                    }
                }
            }
        }
    }
}

3. The problem I’m having:

When I execute the command “caddy stop”, it gives an API error. Caddy restart or even Caddy Upgrade takes ages to get the process done, in the meantime, I have to cancel the operation and using Linux systems service to stop the caddy.

4. Error messages and/or full log output:

If Caddy isn’t running and listening on the admin API endpoint, then caddy stop won’t be able to stop it. That command just sends an HTTP request to the admin endpoint to ask Caddy to stop.

You probably shouldn’t use caddy stop though, you should use the systemctl commands to control Caddy. After you’ve run caddy upgrade, you can restart the service with systemctl restart caddy.

If you’re having trouble with caddy upgrade (which can happen when the build server is acting up – we can’t guarantee reliability) you can build Caddy yourself with xcaddy build --with github.com/dunglas/mercure/caddy which is what the build server does anyway.

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