Suggesting a new module to automatically add packages at caddy startup

I would really like a new module to check if a list of packages are currently installed when caddy is started and install them if not.

Exactly the same functionality as add-package:

caddy add-package

Along with a caddy JSON configuration of, say:

    "packages": [""],

This would be useful if I install and maintain caddy using sudo apt install caddy with updates as part of regular system updates. At the moment, I do this as a manual step which I sometimes forget.

See also new caddy.packages module · Issue #4864 · caddyserver/caddy · GitHub.

That’s an interesting idea. Basically it would have to replace the binary immediately then shut down and “hope” some other process will attempt to restart the process (which systemd should). There’s some danger of potentially causing infinite restart loops though if Caddy isn’t able to start successfully.

Also, it might run into permission problems.
Where the executable might be owned by user root (e.g. apt install default), but the actual process is running as user caddy (current systemd service default).

1 Like

Yeah, good point. This wouldn’t work with systemd, actually.

Issue #4864 has been closed.

Given the challenges with using some variation of the add-package functionality as I suggest above, does anyone have any advice on how to automatically manage updated for non-standard packages?

I still have the problem that my system becomes unusable after caddy is updated.

What do you mean? I don’t see how it should be “unusable”.

You need to systemctl restart caddy after running caddy upgrade, otherwise the upgrade won’t take effect.

1 Like

I did not say that very clearly.

When I do a a periodic system update (sudo apt upgrade) that includes a new version of Caddy, the new binary is installed but without any modules that were installed using caddy add-package.

I guess that the easiest thing is to include Caddy package updates in my system update script, with some error recovery / notification (that prevents update loops).

I am curious how everyone else handles this.

We have instructions for dealing with that here:

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