1. The problem I’m having:
I’ve built a custom module named ‘spartacus’.
When I execute the following - it builds correctly, and seems to run fine:
xcaddy list-modules:
http.handlers.spartacus
Non-standard modules: 1
xcaddy run --config=caddy.json
(runs correctly).
xcaddy build --output=caddy-with-spartacus
(works fine)
But when I execute:
./caddy-with-spartacus -config caddy.json
It says:
❯ ./caddy-with-spartacus run --config caddy.json
2024/05/05 18:21:00.230 INFO using provided configuration {"config_file": "caddy.json", "config_adapter": ""}
2024/05/05 18:21:00.232 INFO admin admin endpoint started {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2024/05/05 18:21:00.232 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0x140003c7080"}
2024/05/05 18:21:00.232 INFO http.auto_https server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS {"server_name": "spartacus_server", "https_port": 443}
2024/05/05 18:21:00.232 INFO http.auto_https enabling automatic HTTP->HTTPS redirects {"server_name": "spartacus_server"}
2024/05/05 18:21:00.234 INFO tls.cache.maintenance stopped background certificate maintenance {"cache": "0x140003c7080"}
Error: loading initial config: loading new config: loading http app module: provision http: server spartacus_server: setting up route handlers: route 0: loading handler modules: position 0: loading module 'spartacus': unknown module: http.handlers.spartacus
Am I missing something?
## 2. Error messages and/or full log output:
<!--
Please DO NOT REDACT any information except credentials. Leave domain names intact!
Please DO NOT POST TRUNCATED LOG LINES as systemd is notorious for this.
Please USE THIS COMMAND TO VIEW LOGS with systemd:
$ journalctl -u caddy --no-pager | less +G`
Please DO NOT USE WEB BROWSERS. Use `curl -vL` instead.
Please ENABLE DEBUG MODE FIRST by adding "debug" to the global options of your Caddyfile. See https://caddyserver.com/docs/caddyfile/options#debug for an example.
-->
❯ ./caddy-with-spartacus run --config caddy.json
2024/05/05 18:39:19.893 INFO using provided configuration {“config_file”: “caddy.json”, “config_adapter”: “”}
2024/05/05 18:39:19.897 INFO admin admin endpoint started {“address”: “localhost:2019”, “enforce_origin”: false, “origins”: [“//localhost:2019”, “//[::1]:2019”, “//127.0.0.1:2019”]}
2024/05/05 18:39:19.898 INFO tls.cache.maintenance started background certificate maintenance {“cache”: “0x140001c4280”}
2024/05/05 18:39:19.898 INFO http.auto_https server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS {“server_name”: “spartacus_server”, “https_port”: 443}
2024/05/05 18:39:19.898 INFO http.auto_https enabling automatic HTTP->HTTPS redirects {“server_name”: “spartacus_server”}
2024/05/05 18:39:19.900 DEBUG http.auto_https adjusted config {“tls”: {“automation”:{“policies”:[{“subjects”:[“localhost”,“127.0.0.1”]},{}]}}, “http”: {“servers”:{“remaining_auto_https_redirects”:{“listen”:[“:80”],“routes”:[{},{}],“logs”:{“default_logger_name”:“spartacusStdOutLogs”}},“spartacus_server”:{“listen”:[“:443”],“routes”:[{“handle”:[{“development”:true,“handler”:“spartacus”,“posthog”:{“endpoint”:“https://1e747868-3524-4d27-ad60-2e73e05bb428.mock.pstmn.io”}}]},{}],“tls_connection_policies”:[{}],“automatic_https”:{},“logs”:{“default_logger_name”:“spartacusStdOutLogs”}}}}}
2024/05/05 18:39:19.900 INFO tls.cache.maintenance stopped background certificate maintenance {“cache”: “0x140001c4280”}
Error: loading initial config: loading new config: loading http app module: provision http: server spartacus_server: setting up route handlers: route 0: loading handler modules: position 0: loading module ‘spartacus’: unknown module: http.handlers.spartacus```
3. Caddy version:
v0.4.0 h1:V4n6nNlkRPmrgE+npteBjS7hgMfw24UEmiIONDpIWSo=
4. How I installed and ran Caddy:
xcaddy build --config caddy.json
./caddy-with-spartacus run --config caddy.json
a. System environment:
MacOS
b. Command:
./caddy-with-spartacus run --config caddy.json
c. Service/unit/compose file:
N/A
d. My complete Caddy config:
{
"logging": {
"logs": {
"default": {
"level": "DEBUG"
}
}
},
"apps": {
"http": {
"servers": {
"spartacus_server": {
"listen": [
":443"
],
"routes": [
{
"handle": [
{
"handler": "spartacus",
"posthog": {
"endpoint": "https://1e747868-3524-4d27-ad60-2e73e05bb428.mock.pstmn.io"
},
"development": true
}
]
},
{
"match": [
{
"host": [
"localhost",
"127.0.0.1"
]
}
]
}
],
"logs": {
"default_logger_name": "spartacusStdOutLogs"
}
}
}
}
}
}```
### 5. Links to relevant resources:
<!-- Optional, but can help get us on the same page quickly. -->