wait for authentik before starting headscale
This commit is contained in:
parent
3491058fc2
commit
c3d604afce
@ -41,26 +41,23 @@ in {
|
|||||||
restartUnits = [ "headscale.service" ];
|
restartUnits = [ "headscale.service" ];
|
||||||
};
|
};
|
||||||
systemd.services.headscale = {
|
systemd.services.headscale = {
|
||||||
serviceConfig.TimeoutStopSec = 10;
|
serviceConfig.TimeoutStopSec = 15;
|
||||||
serviceConfig.ExecStartPre = let
|
serviceConfig.ExecStartPre = let
|
||||||
waitAuthnetikReady = pkgs.writeShellScript "waitAuthnetikReady" ''
|
waitAuthnetikReady = pkgs.writeShellScript "waitAuthnetikReady" ''
|
||||||
# Check until authentik is alive
|
# Check until authentik is alive
|
||||||
retries=0
|
max_retry=100
|
||||||
until [[ curl -fsSL http://auth.ataraxiadev.com/-/health/ready/ ]]; do
|
counter=0
|
||||||
# Wait for 10 minutes
|
until ${lib.getExe pkgs.curl} -fsSL http://auth.ataraxiadev.com/-/health/ready/
|
||||||
[ $retries -ge 200 ] && echo "Could not connect to authentik" && exit 1
|
do
|
||||||
echo "Waiting for the authentik..."
|
echo "Waiting for the authentik..."
|
||||||
sleep 3
|
sleep 3
|
||||||
((retries++))
|
[[ counter -eq $max_retry ]] && echo "Could not connect to authentik!" && exit 1
|
||||||
|
echo "Trying again. Try #$counter"
|
||||||
|
((counter++))
|
||||||
done
|
done
|
||||||
echo "Authentik is alive."
|
echo "Authentik is alive!"
|
||||||
'';
|
'';
|
||||||
in waitAuthnetikReady;
|
in waitAuthnetikReady;
|
||||||
# after = lib.mkIf config.services.authentik.enable [
|
|
||||||
# "authentik-server.service"
|
|
||||||
# "authentik-worker.service"
|
|
||||||
# "nginx.service"
|
|
||||||
# ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
persist.state.directories = [ "/var/lib/headscale" ];
|
persist.state.directories = [ "/var/lib/headscale" ];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user