diff --git a/cmd/tile38-server/main.go b/cmd/tile38-server/main.go index 20658aea..de876dfd 100644 --- a/cmd/tile38-server/main.go +++ b/cmd/tile38-server/main.go @@ -80,6 +80,7 @@ Advanced Options: --http-transport yes/no : HTTP transport (default: yes) --protected-mode yes/no : protected mode (default: yes) --threads num : number of network threads (default: num cores) + --evio yes/no : use the evio package (default: no) Developer Options: --dev : enable developer mode @@ -146,10 +147,10 @@ Developer Options: if i < len(os.Args) { switch strings.ToLower(os.Args[i]) { case "no": - core.ProtectedMode = "no" + core.ProtectedMode = false continue case "yes": - core.ProtectedMode = "yes" + core.ProtectedMode = true continue } } @@ -163,10 +164,10 @@ Developer Options: if i < len(os.Args) { switch strings.ToLower(os.Args[i]) { case "no": - core.AppendOnly = "no" + core.AppendOnly = false continue case "yes": - core.AppendOnly = "yes" + core.AppendOnly = true continue } } @@ -213,6 +214,20 @@ Developer Options: } fmt.Fprintf(os.Stderr, "http-transport must be 'yes' or 'no'\n") os.Exit(1) + case "--evio", "-evio": + i++ + if i < len(os.Args) { + switch strings.ToLower(os.Args[i]) { + case "no": + core.Evio = false + continue + case "yes": + core.Evio = true + continue + } + } + fmt.Fprintf(os.Stderr, "evio must be 'yes' or 'no'\n") + os.Exit(1) } nargs = append(nargs, os.Args[i]) } diff --git a/core/options.go b/core/options.go index 76172062..97776727 100644 --- a/core/options.go +++ b/core/options.go @@ -7,10 +7,10 @@ var DevMode = false var ShowDebugMessages = false // ProtectedMode forces Tile38 to default in protected mode. -var ProtectedMode = "yes" +var ProtectedMode = true // AppendOnly allows for disabling the appendonly file. -var AppendOnly = "yes" +var AppendOnly = true // AppendFileName allows for custom appendonly file path var AppendFileName string @@ -20,3 +20,6 @@ var QueueFileName string // NumThreads is the number of network threads to use. var NumThreads int + +// Evio set the networking to use the evio package. +var Evio = false diff --git a/core/version.go b/core/version.go index 70a0e018..708d09a4 100644 --- a/core/version.go +++ b/core/version.go @@ -1,5 +1,6 @@ package core +// Build variables var ( Version = "0.0.0" // Placeholder for the version BuildTime = "" // Placeholder for the build time diff --git a/internal/server/server.go b/internal/server/server.go index 7915b595..546209e6 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -36,8 +36,6 @@ import ( "github.com/tidwall/tile38/internal/log" ) -const useEvio = false - var errOOM = errors.New("OOM command not allowed when used memory > 'maxmemory'") const goingLive = "going live" @@ -237,7 +235,7 @@ func Serve(host string, port int, dir string, http bool) error { if err := server.migrateAOF(); err != nil { return err } - if core.AppendOnly == "yes" { + if core.AppendOnly == true { f, err := os.OpenFile(core.AppendFileName, os.O_CREATE|os.O_RDWR, 0600) if err != nil { return err @@ -272,14 +270,14 @@ func Serve(host string, port int, dir string, http bool) error { }() // Start the network server - if useEvio { + if core.Evio { return server.evioServe() } return server.netServe() } func (server *Server) isProtected() bool { - if core.ProtectedMode == "no" { + if core.ProtectedMode == false { // --protected-mode no return false }