54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"git.entr0py.de/garionion/catie/internal/config"
|
|
"git.entr0py.de/garionion/catie/internal/gstreamer"
|
|
"github.com/rs/zerolog"
|
|
"github.com/rs/zerolog/log"
|
|
"github.com/rs/zerolog/pkgerrors"
|
|
"os"
|
|
"sync"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
zerolog.TimeFieldFormat = time.RFC1123Z
|
|
consoleWriter := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC1123Z}
|
|
log.Logger = log.Output(consoleWriter).With().Timestamp().Caller().Logger()
|
|
|
|
// --- Configuration Loading ---
|
|
configPath := flag.String("config", "config.toml", "Path to the configuration file")
|
|
flag.Parse()
|
|
|
|
cfg, err := config.LoadConfig(*configPath)
|
|
if err != nil {
|
|
log.Fatal().Err(err).Msgf("Failed to load configuration from %s", *configPath)
|
|
}
|
|
|
|
// --- Logging Setup ---
|
|
if cfg.Debug {
|
|
zerolog.SetGlobalLevel(zerolog.DebugLevel)
|
|
}
|
|
|
|
if log.Logger.GetLevel() == zerolog.DebugLevel {
|
|
zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack
|
|
}
|
|
|
|
log.Debug().Interface("config", cfg).Msg("starting application")
|
|
|
|
gst, err := gstreamer.New(cfg.Pipeline, cfg.Outputs, cfg.Debug)
|
|
if err != nil {
|
|
log.Fatal().Err(err).Msg("Failed to create gstreamer")
|
|
}
|
|
|
|
var wg sync.WaitGroup
|
|
wg.Add(1)
|
|
if err := gst.Run(); err != nil {
|
|
log.Fatal().Err(err).Msg("Failed to run gstreamer")
|
|
wg.Done()
|
|
}
|
|
|
|
log.Info().Msg("Gstreamer is running")
|
|
wg.Wait()
|
|
}
|