refactor(controller): added env and other fixes to account for running as a service

This commit is contained in:
2025-09-08 16:08:30 -05:00
parent ddfeb5ccb5
commit fc7ecb6ab6
4 changed files with 43 additions and 25 deletions

View File

@@ -88,16 +88,18 @@ func copyLatestBuild(server *socketio.Server, target string) {
func triggerRemoteUpdate(server *socketio.Server, remoteURL string, payload UpdatePayload) {
// basePath := "/api/controller"
// if os.Getenv("NODE_ENV") != "production" {
// basePath = "/lst/api/controller"
// }
fmt.Println("running the update process")
basePath := "/api/controller"
if os.Getenv("NODE_ENV") != "production" {
basePath = "/lst/api/controller"
}
// send POST request with JSON, expect SSE / streaming text back
body, _ := json.Marshal(payload)
//url := fmt.Sprintf("https://%v.alpla.net%v/update", remoteURL, basePath)
url := fmt.Sprintf("http://%v:8080/api/controller/update", remoteURL)
url := fmt.Sprintf("https://%v.alpla.net%v/update", remoteURL, basePath)
fmt.Println(url)
//url := fmt.Sprintf("http://%v:8080/api/controller/update", remoteURL)
fmt.Println(url)
resp, err := http.Post(url, "application/json", bytes.NewBuffer(body))
if err != nil {