mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2026-03-15 14:03:17 +08:00
add headless mode
This commit is contained in:
20
app/main.go
20
app/main.go
@@ -11,10 +11,13 @@ import (
|
||||
"AynaLivePlayer/pkg/logger"
|
||||
loggerRepo "AynaLivePlayer/pkg/logger/repository"
|
||||
"flag"
|
||||
"os"
|
||||
"os/signal"
|
||||
"time"
|
||||
)
|
||||
|
||||
var dev = flag.Bool("dev", false, "dev")
|
||||
var headless = flag.Bool("headless", false, "headless")
|
||||
|
||||
type _LogConfig struct {
|
||||
config.BaseConfig
|
||||
@@ -50,14 +53,20 @@ func main() {
|
||||
global.Logger.Info("================Program Start================")
|
||||
global.Logger.Infof("================Current Version: %s================", model.Version(config.Version))
|
||||
internal.Initialize()
|
||||
gui.Initialize()
|
||||
go func() {
|
||||
// temporary fix for gui not render correctly.
|
||||
// wait until gui rendered then start event dispatching
|
||||
time.Sleep(1 * time.Second)
|
||||
global.EventManager.Start()
|
||||
}()
|
||||
gui.MainWindow.ShowAndRun()
|
||||
if *headless || config.Experimental.Headless {
|
||||
quit := make(chan os.Signal)
|
||||
signal.Notify(quit, os.Interrupt)
|
||||
<-quit
|
||||
} else {
|
||||
gui.Initialize()
|
||||
gui.MainWindow.ShowAndRun()
|
||||
}
|
||||
global.Logger.Info("closing internal server")
|
||||
internal.Stop()
|
||||
global.Logger.Infof("closing event manager")
|
||||
@@ -66,6 +75,11 @@ func main() {
|
||||
global.Logger.Infof("saving translation")
|
||||
i18n.SaveTranslation()
|
||||
}
|
||||
_ = config.SaveToConfigFile(config.ConfigPath)
|
||||
err := config.SaveToConfigFile(config.ConfigPath)
|
||||
if err != nil {
|
||||
global.Logger.Errorf("save config failed: %v", err)
|
||||
} else {
|
||||
global.Logger.Infof("save config success")
|
||||
}
|
||||
global.Logger.Info("================Program End================")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user