mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
Parse flat before load config (#275)
* Parse flat before load config * Bump version to 0.9.11
This commit is contained in:
parent
523294e6d1
commit
5d265dce33
@ -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"
|
||||||
|
@ -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 {
|
||||||
|
@ -47,13 +47,6 @@ 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(`
|
||||||
▌ ▌ ▌ ▛▀▖ ▞▀▖ ▞▀▖
|
▌ ▌ ▌ ▛▀▖ ▞▀▖ ▞▀▖
|
||||||
@ -63,7 +56,8 @@ func main() {
|
|||||||
|
|
||||||
WebP Server Go - v%s
|
WebP Server Go - v%s
|
||||||
Develop by WebP Server team. https://github.com/webp-sh`, config.Version)
|
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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user