package main

import (
	"context"

	"github.com/fiskerinc/cloud-services/services/jetfire/controllers"
	"github.com/fiskerinc/cloud-services/services/jetfire/server"
	"github.com/fiskerinc/cloud-services/services/jetfire/services"

	"github.com/fiskerinc/cloud-services/pkg/kafka"
	"github.com/fiskerinc/cloud-services/pkg/logger"
	"github.com/fiskerinc/cloud-services/pkg/tracer"
	"github.com/fiskerinc/cloud-services/pkg/utils/app"
)

var (
	SERVICE_NAME = "jetfire"
)

func init() {
	app.Setup(SERVICE_NAME, cleanup)
}

func main() {

	defer cleanup()

	tracer.Start()
	defer tracer.Stop()

	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	go controllers.HealthCheck()

	services.ResetCacheVars()
	go server.StartHTTPServer() //listen for reset requests
	go server.StartConsumer(ctx, kafka.VehicleSignal)

	select {}
}

func cleanup() {
	logger.Close()
}
