Skip to content

Commit 1f5a34b

Browse files
chore: Add selective Edgehog provisioning commands to justfile (#1018)
Add new justfile tasks to provision and deprovision Edgehog independently of Astarte, enabling faster development iterations without the overhead of recreating the entire Astarte infrastructure. - Add `provision-edgehog` task that checks for existing Astarte installation and provisions it only if needed, then sets up Edgehog services and creates the tenant - Add `deprovision-edgehog` task that tears down Edgehog and device runtime while preserving the Astarte cluster Usage: just provision-edgehog # Set up Edgehog (creates Astarte if missing) just deprovision-edgehog # Tear down Edgehog (keep Astarte) Signed-off-by: Omar <omar.brbutovic@secomind.com>
1 parent 3ffa28a commit 1f5a34b

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

justfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,36 @@ _create-edgehog-tenant:
125125
}
126126
}'
127127

128+
# Check if Astarte is running and start it if needed
129+
[private]
130+
_ensure-astarte-running:
131+
#!/usr/bin/env bash
132+
echo "🔍 Checking if Astarte is running..."
133+
if curl -sf http://api.astarte.localhost/appengine/health >/dev/null && \
134+
curl -sf http://api.astarte.localhost/realmmanagement/health >/dev/null && \
135+
curl -sf http://api.astarte.localhost/pairing/health >/dev/null && \
136+
curl -sf http://api.astarte.localhost/housekeeping/health >/dev/null; then
137+
echo "✅ Astarte is already running."
138+
else
139+
echo "⚠️ Astarte is not running. Starting Astarte..."
140+
just _check-astarte-prereqs
141+
just _configure-system
142+
just _init-astarte
143+
just _wait-astarte
144+
echo "🏠 Checking if realm exists..."
145+
if ! astartectl housekeeping realms list --astarte-url http://api.astarte.localhost -k astarte/compose/astarte-keys/housekeeping_private.pem | grep -q "test"; then
146+
echo "🏠 Realm does not exist, creating it..."
147+
just _create-astarte-realm
148+
else
149+
echo "✅ Realm already exists."
150+
fi
151+
fi
152+
153+
# Provision only Edgehog (will start Astarte if not running)
154+
provision-edgehog: _check-system-prereqs _ensure-astarte-running _init-edgehog _wait-edgehog _create-edgehog-tenant
155+
@echo "🎉 Edgehog has been provisioned with the test tenant."
156+
@just open-dashboards
157+
128158
# Provision a new Edgehog tenant with Astarte backend
129159
provision-tenant: _check-system-prereqs _check-astarte-prereqs _configure-system _init-astarte _wait-astarte _create-astarte-realm _init-edgehog _wait-edgehog _create-edgehog-tenant
130160
@echo "🎉 The Edgehog cluster has been provisioned and the tenant is ready."
@@ -138,6 +168,17 @@ deprovision-tenant: _check-system-prereqs && _clean-resources
138168
@if [ -d astarte ]; then echo "🛑 Deprovisioning Astarte..."; (cd astarte && docker compose down -v); fi
139169
@echo "✅ The Edgehog cluster has been deprovisioned."
140170

171+
# Deprovision only Edgehog and device runtime, leave Astarte running
172+
deprovision-edgehog:
173+
@echo "🧹 Deprovisioning Edgehog and device runtime..."
174+
@echo "🛑 Stopping Edgehog services..."
175+
docker compose down -v
176+
@echo "🧹 Cleaning up device runtime files..."
177+
-rm -rf edgehog-device-runtime/.store/
178+
-rm -rf edgehog-device-runtime/.updates/
179+
-rm -rf edgehog-device-runtime/
180+
@echo "✅ Edgehog and device runtime have been deprovisioned. Astarte is still running."
181+
141182
# Initialize device runtime repository
142183
[private]
143184
_init-device-runtime:
@@ -242,8 +283,10 @@ help:
242283
@echo ""
243284
@echo "Main commands:"
244285
@echo " provision-tenant Set up Edgehog with Astarte backend"
286+
@echo " provision-edgehog Set up Edgehog (will start Astarte if not running)"
245287
@echo " connect-device Connect a simulated device to Edgehog"
246288
@echo " deprovision-tenant Tear down Edgehog and Astarte services"
289+
@echo " deprovision-edgehog Tear down Edgehog and device runtime (keep Astarte)"
247290
@echo ""
248291
@echo "Utility commands:"
249292
@echo " status Show the status of running services"

0 commit comments

Comments
 (0)