summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/main.go b/main.go
index 90e0d6a..e50dbba 100644
--- a/main.go
+++ b/main.go
@@ -9,6 +9,7 @@ import (
"context"
"fmt"
"github.com/akamensky/argparse"
+ "github.com/keuin/slbr/api"
"github.com/keuin/slbr/logging"
"github.com/keuin/slbr/recording"
"github.com/keuin/slbr/types"
@@ -153,7 +154,7 @@ func getTasks() (tasks []recording.TaskConfig) {
func main() {
logger := log.Default()
taskConfigs := getTasks()
- tasks := make([]recording.RunningTask, len(taskConfigs))
+ tasks := make([]*recording.RunningTask, len(taskConfigs))
wg := sync.WaitGroup{}
ctxTasks, cancelTasks := context.WithCancel(context.Background())
@@ -170,6 +171,21 @@ func main() {
}
fmt.Println("")
+ apiAddr := os.Getenv("BIND_ADDR")
+ if apiAddr == "" {
+ apiAddr = ":8080"
+ }
+ apiAgent := &agentImpl{
+ tasks: &tasks,
+ }
+ go func() {
+ logger.Println("Starting API server...")
+ err := api.StartServer(apiAddr, apiAgent)
+ if err != nil {
+ logger.Fatalf("Failed to start API server: %v", err)
+ }
+ }()
+
logger.Printf("Starting tasks...")
for i := range tasks {