Parse flat before load config (#275)

* Parse flat before load config

* Bump version to 0.9.11
This commit is contained in:
Nova Kwok 2023-09-15 14:13:30 +08:00 committed by GitHub
parent 523294e6d1
commit 5d265dce33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 19 deletions

View File

@ -59,7 +59,7 @@ var (
ProxyMode bool ProxyMode bool
Prefetch bool Prefetch bool
Config jsonFile Config jsonFile
Version = "0.9.9" Version = "0.9.11"
WriteLock = cache.New(5*time.Minute, 10*time.Minute) WriteLock = cache.New(5*time.Minute, 10*time.Minute)
RemoteRaw = "./remote-raw" RemoteRaw = "./remote-raw"
Metadata = "./metadata" Metadata = "./metadata"

View File

@ -20,12 +20,12 @@ var (
) )
func init() { func init() {
vips.LoggingSettings(nil, vips.LogLevelError)
vips.Startup(&vips.Config{ vips.Startup(&vips.Config{
ConcurrencyLevel: runtime.NumCPU(), ConcurrencyLevel: runtime.NumCPU(),
}) })
boolFalse.Set(false) boolFalse.Set(false)
intMinusOne.Set(-1) intMinusOne.Set(-1)
} }
func resizeImage(img *vips.ImageRef, extraParams config.ExtraParams) error { func resizeImage(img *vips.ImageRef, extraParams config.ExtraParams) error {

View File

@ -47,23 +47,17 @@ func setupLogger() {
} }
func init() { func init() {
// main init is the last one to be called
flag.Parse()
config.LoadConfig()
setupLogger()
}
func main() {
// Our banner // Our banner
banner := fmt.Sprintf(` banner := fmt.Sprintf(`
WebP Server Go - v%s
Develop by WebP Server team. https://github.com/webp-sh`, config.Version)
WebP Server Go - v%s
Develop by WebP Server team. https://github.com/webp-sh`, config.Version)
// main init is the last one to be called
flag.Parse()
// process cli params // process cli params
if config.DumpConfig { if config.DumpConfig {
fmt.Println(config.SampleConfig) fmt.Println(config.SampleConfig)
@ -77,11 +71,15 @@ Develop by WebP Server team. https://github.com/webp-sh`, config.Version)
fmt.Printf("\n %c[1;32m%s%c[0m\n\n", 0x1B, banner+"", 0x1B) fmt.Printf("\n %c[1;32m%s%c[0m\n\n", 0x1B, banner+"", 0x1B)
os.Exit(0) os.Exit(0)
} }
config.LoadConfig()
fmt.Printf("\n %c[1;32m%s%c[0m\n\n", 0x1B, banner, 0x1B)
setupLogger()
}
func main() {
if config.Prefetch { if config.Prefetch {
go encoder.PrefetchImages() go encoder.PrefetchImages()
} }
app.Use(etag.New(etag.Config{ app.Use(etag.New(etag.Config{
Weak: true, Weak: true,
})) }))
@ -89,7 +87,6 @@ Develop by WebP Server team. https://github.com/webp-sh`, config.Version)
listenAddress := config.Config.Host + ":" + config.Config.Port listenAddress := config.Config.Host + ":" + config.Config.Port
app.Get("/*", handler.Convert) app.Get("/*", handler.Convert)
fmt.Printf("\n %c[1;32m%s%c[0m\n\n", 0x1B, banner, 0x1B)
fmt.Println("WebP Server Go is Running on http://" + listenAddress) fmt.Println("WebP Server Go is Running on http://" + listenAddress)
_ = app.Listen(listenAddress) _ = app.Listen(listenAddress)