package main import ( "os" "os/signal" "syscall" "time" ) func main() { // Init exit channel end := make(chan os.Signal, 1) signal.Notify(end, syscall.SIGINT, syscall.SIGTERM) // Load config.toml file loadConfig("config", &config) // Initialize REST API go initApi() // Initialize enabled audio backends if config.Jack.Enabled { initJack() } // Start audio routing startRouting() // Periodically save config files ticker := time.NewTicker(5 * time.Second) go func() { for { select { case <-ticker.C: saveConfigIfMarked("ports", portConfig) case <-end: ticker.Stop() return } } }() // Wait until SIGINT received <-end if config.Jack.Enabled { stopJack() } }