mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-05 16:57:06 +08:00
bug fix: default config
This commit is contained in:
@@ -29,7 +29,7 @@ You can get runnable program in the releases of this repository, which supports
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
You could use redis-cli or other redis client to connect godis server, which listens on 127.0.0.1:6379 on default mode.
|
You could use redis-cli or other redis client to connect godis server, which listens on 0.0.0.0:6399 on default mode.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@ Godis 的信息。
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
godis 默认监听 127.0.0.1:6379,可以使用 redis-cli 或者其它 redis 客户端连接 Godis 服务器。
|
godis 默认监听 0.0.0.0:6399,可以使用 redis-cli 或者其它 redis 客户端连接 Godis 服务器。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
2
build-all.sh
Normal file
2
build-all.sh
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
./build-darwin.sh
|
||||||
|
./build-linux.sh
|
38
cmd/main.go
38
cmd/main.go
@@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "embed"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/hdt3213/godis/config"
|
"github.com/hdt3213/godis/config"
|
||||||
"github.com/hdt3213/godis/lib/logger"
|
"github.com/hdt3213/godis/lib/logger"
|
||||||
@@ -10,22 +9,45 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed banner.txt
|
var banner = `
|
||||||
var banner string
|
______ ___
|
||||||
|
/ ____/___ ____/ (_)____
|
||||||
|
/ / __/ __ \/ __ / / ___/
|
||||||
|
/ /_/ / /_/ / /_/ / (__ )
|
||||||
|
\____/\____/\__,_/_/____/
|
||||||
|
`
|
||||||
|
|
||||||
|
var defaultProperties = &config.ServerProperties{
|
||||||
|
Bind: "0.0.0.0",
|
||||||
|
Port: 6399,
|
||||||
|
AppendOnly: false,
|
||||||
|
AppendFilename: "",
|
||||||
|
MaxClients: 1000,
|
||||||
|
}
|
||||||
|
|
||||||
|
func fileExists(filename string) bool {
|
||||||
|
info, err := os.Stat(filename)
|
||||||
|
return err != nil && !info.IsDir()
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
print(banner)
|
print(banner)
|
||||||
configFilename := os.Getenv("CONFIG")
|
|
||||||
if configFilename == "" {
|
|
||||||
configFilename = "redis.conf"
|
|
||||||
}
|
|
||||||
config.SetupConfig(configFilename)
|
|
||||||
logger.Setup(&logger.Settings{
|
logger.Setup(&logger.Settings{
|
||||||
Path: "logs",
|
Path: "logs",
|
||||||
Name: "godis",
|
Name: "godis",
|
||||||
Ext: ".log",
|
Ext: ".log",
|
||||||
TimeFormat: "2006-01-02",
|
TimeFormat: "2006-01-02",
|
||||||
})
|
})
|
||||||
|
configFilename := os.Getenv("CONFIG")
|
||||||
|
if configFilename == "" {
|
||||||
|
if fileExists("redis.conf") {
|
||||||
|
config.SetupConfig("redis.conf")
|
||||||
|
} else {
|
||||||
|
config.Properties = defaultProperties
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
config.SetupConfig(configFilename)
|
||||||
|
}
|
||||||
|
|
||||||
err := tcp.ListenAndServeWithSignal(&tcp.Config{
|
err := tcp.ListenAndServeWithSignal(&tcp.Config{
|
||||||
Address: fmt.Sprintf("%s:%d", config.Properties.Bind, config.Properties.Port),
|
Address: fmt.Sprintf("%s:%d", config.Properties.Bind, config.Properties.Port),
|
||||||
|
Reference in New Issue
Block a user