mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-28 05:46:36 +08:00
699e95f12c
Result: {"status":"keep","total_issues":56,"golint_canonicalheader":8,"golint_errname":1,"golint_errorlint":12,"golint_forcetypeassert":3,"golint_gosec":0,"golint_intrange":3,"golint_modernize":5,"golint_nilnil":3,"golint_perfsprint":0,"golint_prealloc":3,"golint_recvcheck":7,"golint_usestdlibvars":3,"golint_wastedassign":7,"golint_total":55,"eslint_problems":1,"eslint_errors":0,"eslint_warnings":1,"tsc_errors":0,"measure_s":47}
69 lines
1.8 KiB
Go
69 lines
1.8 KiB
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"runtime"
|
|
"strings"
|
|
|
|
"github.com/Rain-kl/Wavelet/internal/buildinfo"
|
|
"github.com/Rain-kl/Wavelet/internal/infra/config"
|
|
"github.com/Rain-kl/Wavelet/internal/infra/persistence/migrator"
|
|
)
|
|
|
|
type startupState struct {
|
|
mode string
|
|
relationalDB migrator.Report
|
|
clickHouseDB migrator.Report
|
|
listensForHTTP bool
|
|
}
|
|
|
|
func printStartupBanner(state startupState) {
|
|
log.Print(formatStartupBanner(state))
|
|
}
|
|
|
|
func formatStartupBanner(state startupState) string {
|
|
lines := []string{
|
|
"",
|
|
" ____ ________ ",
|
|
" / __ \\____ ___ ____ / ____/ /___ _________ ",
|
|
" / / / / __ \\/ _ \\/ __ \\/ /_ / / __ `/ ___/ _ \\",
|
|
"/ /_/ / /_/ / __/ / / / __/ / / /_/ / / / __/",
|
|
"\\____/ .___/\\___/_/ /_/_/ /_/\\__,_/_/ \\___/ ",
|
|
" /_/ ",
|
|
" OpenFlare " + buildinfo.Version,
|
|
"",
|
|
" Environment: " + config.Config.App.Env,
|
|
fmt.Sprintf(" Runtime: %s/%s (%s)", runtime.GOOS, runtime.GOARCH, runtime.Version()),
|
|
" Build time: " + buildTime(),
|
|
" Database: " + formatMigration(state.relationalDB),
|
|
" Analytics: " + formatMigration(state.clickHouseDB),
|
|
}
|
|
if state.listensForHTTP {
|
|
lines = append(lines, " Listening: http://"+config.Config.App.Addr)
|
|
}
|
|
lines = append(lines, " Mode: "+state.mode, "")
|
|
return strings.Join(lines, "\n")
|
|
}
|
|
|
|
func buildTime() string {
|
|
if buildinfo.BuildTime == "" {
|
|
return "development build"
|
|
}
|
|
return buildinfo.BuildTime
|
|
}
|
|
|
|
func formatMigration(report migrator.Report) string {
|
|
if !report.Enabled {
|
|
return "disabled"
|
|
}
|
|
state := "up to date"
|
|
if report.Applied {
|
|
state = "upgraded"
|
|
}
|
|
return fmt.Sprintf("%s (version %d, %s)", report.Backend, report.Version, state)
|
|
}
|