From 445bc41d0efd39991ff2d5435e28bca245763190 Mon Sep 17 00:00:00 2001 From: Paulo Truta Date: Sat, 28 Oct 2023 18:43:18 +0200 Subject: [PATCH] Fixes to install make command, fixes to local network app url definition, run ws build on start and every 24 hours --- Makefile | 3 ++- internal/edgeapps/edgeapps.go | 2 +- internal/system/system.go | 8 ++++++++ internal/tasks/tasks.go | 12 ++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2faaf7d..ca58644 100644 --- a/Makefile +++ b/Makefile @@ -42,8 +42,9 @@ test-with-coverage: install: sudo systemctl stop edgeboxctl - sudo rm -rf /usr/local/bin/edgeboxctl /lib/systemd/system/edgeboxctl.service + sudo rm -rf /usr/local/bin/edgeboxctl /usr/local/sbin/edgeboctl /lib/systemd/system/edgeboxctl.service sudo cp ./bin/edgeboxctl /usr/local/bin/edgeboxctl + sudo cp ./bin/edgeboxctl /usr/local/sbin/edgeboxctl sudo cp ./edgeboxctl.service /lib/systemd/system/edgeboxctl.service sudo systemctl daemon-reload @echo "Edgeboxctl installed successfully" diff --git a/internal/edgeapps/edgeapps.go b/internal/edgeapps/edgeapps.go index 83b10ea..e0b66d5 100644 --- a/internal/edgeapps/edgeapps.go +++ b/internal/edgeapps/edgeapps.go @@ -98,7 +98,7 @@ func GetEdgeApp(ID string) MaybeEdgeApp { Status: GetEdgeAppStatus(ID), Services: GetEdgeAppServices(ID), InternetAccessible: edgeAppInternetAccessible, - NetworkURL: ID + system.GetHostname() + ".local", + NetworkURL: ID + "." + system.GetHostname() + ".local", InternetURL: edgeAppInternetURL, }, Valid: true, diff --git a/internal/system/system.go b/internal/system/system.go index 12e8c5d..82cb34d 100644 --- a/internal/system/system.go +++ b/internal/system/system.go @@ -100,6 +100,14 @@ func SetupCloudOptions() { utils.Exec("/", "rm", []string{cloudEnvFileLocationPath}) } +// StartWs: Starts the webserver service for Edgeapps +func StartWs() { + wsPath := utils.GetPath(utils.WsPath) + fmt.Println("Starting WS") + cmdargs := []string{"-b"} + utils.Exec(wsPath, "./ws", cmdargs) +} + // StartService: Starts a service func StartService(serviceID string) { wsPath := utils.GetPath(utils.WsPath) diff --git a/internal/tasks/tasks.go b/internal/tasks/tasks.go index a88c101..051cdfb 100644 --- a/internal/tasks/tasks.go +++ b/internal/tasks/tasks.go @@ -374,6 +374,7 @@ func ExecuteSchedules(tick int) { log.Println("Uptime is " + uptime + " seconds (" + system.GetUptimeFormatted() + ")") log.Println(taskGetStorageDevices()) + taskStartWs() log.Println(taskGetEdgeApps()) } @@ -423,6 +424,12 @@ func ExecuteSchedules(tick int) { // Executing every 3600 ticks (1 hour) } + if tick%86400 == 0 { + // Executing every 86400 ticks (+/1 day) + // Ensuring we run a normal build, setting up avahi domain names fresh in the network + taskStartWs() + } + // Just add a schedule here if you need a custom one (every "tick hour", every "tick day", etc...) } @@ -1000,3 +1007,8 @@ func taskSetupCloudOptions() { fmt.Println("Executing taskSetupCloudOptions") system.SetupCloudOptions() } + +func taskStartWs() { + fmt.Println("Executing taskStartWs") + system.StartWs() +}