Server/caddy: wait for tailscale ip before starting
This commit is contained in:
parent
e863aea052
commit
d8f2812003
1 changed files with 14 additions and 0 deletions
|
|
@ -11,6 +11,19 @@
|
|||
file_server browse
|
||||
root * /srv/dl/
|
||||
'';
|
||||
script = pkgs.writeShellApplication {
|
||||
name = "wait-for-tailscale-ip";
|
||||
runtimeInputs = [pkgs.iproute2];
|
||||
text = ''
|
||||
# Based on https://github.com/tailscale/tailscale/issues/11504#issuecomment-2113331262
|
||||
echo Waiting for tailscale0 to get an IP adress..
|
||||
for i in {1..300}; do
|
||||
if ip addr show dev tailscale0 | grep -q 'inet '; then break; fi
|
||||
echo "Waiting $i/240 seconds"
|
||||
sleep 1
|
||||
done
|
||||
'';
|
||||
};
|
||||
in {
|
||||
services.caddy = {
|
||||
enable = true;
|
||||
|
|
@ -71,6 +84,7 @@ in {
|
|||
# in too little time
|
||||
services.caddy.serviceConfig.RestartSec = lib.mkForce "120s";
|
||||
services.caddy.unitConfig.StartLimitBurst = lib.mkForce "infinity";
|
||||
services.caddy.preStart = "${script}/bin/wait-for-tailscale-ip";
|
||||
};
|
||||
programs.rust-motd.settings.service_status.Caddy = "caddy";
|
||||
networking.firewall.allowedTCPPorts = [443 80];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue