File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 103103 } ;
104104 } ;
105105
106+ systemd . services . csf-cp-ready = {
107+ description = "CSF Control Plane readiness check" ;
108+ wantedBy = [ "multi-user.target" ] ;
109+ after = [ "csf-cp.service" ] ;
110+ requires = [ "csf-cp.service" ] ;
111+
112+ serviceConfig = {
113+ Type = "oneshot" ;
114+ RemainAfterExit = true ;
115+ User = "root" ;
116+ ExecStart = pkgs . writeShellScript "csf-cp-ready" ''
117+ set -euo pipefail
118+
119+ CURL=${ pkgs . curl } /bin/curl
120+ TIMEOUT=120
121+ ELAPSED=0
122+
123+ echo "CSF Control Plane starting..." > /dev/tty1
124+
125+ while [ "$ELAPSED" -lt "$TIMEOUT" ]; do
126+ if "$CURL" -sf http://localhost:8000/api/public-key > /dev/null 2>&1; then
127+ IP=$(hostname -I | awk '{print $1}')
128+ echo "" > /dev/tty1
129+ echo "CSF Control Plane ready." > /dev/tty1
130+ echo "API: http://$IP:8000" > /dev/tty1
131+ exit 0
132+ fi
133+
134+ echo "Waiting for API gateway... ('' ${ELAPSED}s)" > /dev/tty1
135+ sleep 5
136+ ELAPSED=$((ELAPSED + 5))
137+ done
138+
139+ echo "CSF Control Plane did not become ready within '' ${TIMEOUT}s" > /dev/tty1
140+ echo "Check: sudo docker logs csf-csf-api-gateway-1" > /dev/tty1
141+ exit 1
142+ '' ;
143+ } ;
144+ } ;
145+
106146 virtualisation . docker . enable = true ;
107147
108148 environment . systemPackages = [ pkgs . docker-compose ] ;
You can’t perform that action at this time.
0 commit comments