improve initialization flow

This commit is contained in:
yusing
2025-02-15 11:21:29 +08:00
parent 9731d28ec3
commit 01432fa778
9 changed files with 82 additions and 81 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"log"
"os"
"sync"
"github.com/yusing/go-proxy/internal"
"github.com/yusing/go-proxy/internal/api/v1/auth"
@@ -22,6 +23,18 @@ import (
var rawLogger = log.New(os.Stdout, "", 0)
func parallel(fns ...func()) {
var wg sync.WaitGroup
for _, fn := range fns {
wg.Add(1)
go func() {
defer wg.Done()
fn()
}()
}
wg.Wait()
}
func main() {
initProfiling()
args := pkg.GetArgs(common.MainServerCommandValidator{})
@@ -64,6 +77,11 @@ func main() {
if args.Command == common.CommandStart {
logging.Info().Msgf("GoDoxy version %s", pkg.GetVersion())
logging.Trace().Msg("trace enabled")
parallel(
internal.InitIconListCache,
homepage.InitOverridesConfig,
favicon.InitIconCache,
)
// logging.AddHook(notif.GetDispatcher())
} else {
logging.DiscardLogger()
@@ -109,10 +127,6 @@ func main() {
return
}
go internal.InitIconListCache()
go homepage.InitOverridesConfig()
go favicon.InitIconCache()
cfg.Start(&config.StartServersOptions{
Proxy: true,
})