package main import ( // "context" "fmt" "os" "os/signal" // "sync" "syscall" ) func main() { // var program1 = os.Getenv("BUILD_COMMAND") //var program2 = os.Getenv("RUN_COMMAND") var watchedDir = os.Getenv("WATCHED_DIR") // Create context for graceful shutdown // ctx, cancel := context.WithCancel(context.Background()) //defer cancel() // Setup signal handling sigCh := make(chan os.Signal, 1) signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM) fileChanges := make(chan FileChange, 10) go watchFiles(watchedDir, fileChanges) go runExpress(fileChanges) // WaitGroup to track both processes // var wg sync.WaitGroup // Start both processes //wg.Add(2) // go runProcess(ctx, &wg, "builder", program1) // go runProcess(ctx, &wg, "runner", program2) // Wait for interrupt signal <-sigCh fmt.Println("\nReceived interrupt signal, shutting down...") // Cancel context to signal goroutines to stop /// cancel() // Wait for both processes to finish // wg.Wait() fmt.Println("All processes terminated cleanly") }