mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-06 19:07:50 +00:00
add plugins path arg to server
also fix an issue where tests would hang if an invalid config file was given
This commit is contained in:
parent
9a18fc11a6
commit
b291307dde
3 changed files with 14 additions and 12 deletions
|
|
@ -80,6 +80,7 @@ on the configured port.`,
|
|||
flags.IntVarP(&Serve.Config.Cluster.ReplicaN, "cluster.replicas", "", 1, "Number hosts each piece of data should be stored on.")
|
||||
flags.StringSliceVarP(&Serve.Config.Cluster.Nodes, "cluster.hosts", "", []string{}, "Comma separated list of hosts in cluster.")
|
||||
flags.DurationVarP((*time.Duration)(&Serve.Config.Cluster.PollingInterval), "cluster.poll-interval", "", time.Minute, "Polling interval for cluster.") // TODO what actually is this?
|
||||
flags.StringVarP(&Serve.Config.Plugins.Path, "plugins.path", "", "", "Path to plugin directory.")
|
||||
flags.StringVarP(&Serve.CPUProfile, "cpu-profile", "", "", "Where to store CPU profile.")
|
||||
flags.DurationVarP(&Serve.CPUTime, "cpu-time", "", 30*time.Second, "CPU profile duration.")
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import (
|
|||
"io/ioutil"
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
@ -83,10 +82,13 @@ bind = "localhost:0"
|
|||
hosts = [
|
||||
"localhost:19444",
|
||||
]
|
||||
[plugins]
|
||||
path = "/var/sloth"
|
||||
`,
|
||||
validation: func() error {
|
||||
v := validator{}
|
||||
v.Check(cmd.Serve.Config.Cluster.Nodes, []string{"example.com:1110", "example.com:1111"})
|
||||
v.Check(cmd.Serve.Config.Plugins.Path, "/var/sloth")
|
||||
return v.Error()
|
||||
},
|
||||
},
|
||||
|
|
@ -113,18 +115,19 @@ bind = "localhost:0"
|
|||
|
||||
for i, test := range tests {
|
||||
com := test.setupCommand(t)
|
||||
wait := sync.Mutex{}
|
||||
wait.Lock()
|
||||
executed := make(chan struct{})
|
||||
var execErr error
|
||||
go func() {
|
||||
execErr = com.Execute()
|
||||
wait.Unlock()
|
||||
close(executed)
|
||||
}()
|
||||
// Serve.Close automatically waits for Serve.Run() to finish starting
|
||||
// the server.
|
||||
select {
|
||||
case <-cmd.Serve.Started:
|
||||
case <-executed:
|
||||
}
|
||||
err := cmd.Serve.Close()
|
||||
failErr(t, err, "closing pilosa server command")
|
||||
wait.Lock() // make sure com.Execute finishes
|
||||
<-executed
|
||||
failErr(t, execErr, "executing command")
|
||||
|
||||
if err := test.validation(); err != nil {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ type Command struct {
|
|||
Stderr io.Writer
|
||||
|
||||
// running will be closed once Command.Run is finished.
|
||||
running chan struct{}
|
||||
Started chan struct{}
|
||||
// Done will be closed when Command.Close() is called
|
||||
Done chan struct{}
|
||||
}
|
||||
|
|
@ -55,14 +55,14 @@ func NewCommand() *Command {
|
|||
Stdout: os.Stdout,
|
||||
Stderr: os.Stderr,
|
||||
|
||||
running: make(chan struct{}),
|
||||
Started: make(chan struct{}),
|
||||
Done: make(chan struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
// Run executes the pilosa server.
|
||||
func (m *Command) Run(args ...string) error {
|
||||
defer close(m.running)
|
||||
defer close(m.Started)
|
||||
prefix := "~" + string(filepath.Separator)
|
||||
if strings.HasPrefix(m.Config.DataDir, prefix) {
|
||||
HomeDir := os.Getenv("HOME")
|
||||
|
|
@ -97,8 +97,6 @@ func (m *Command) Run(args ...string) error {
|
|||
|
||||
// Close shuts down the server.
|
||||
func (m *Command) Close() error {
|
||||
// must be running before it can be closed
|
||||
<-m.running
|
||||
err := m.Server.Close()
|
||||
close(m.Done)
|
||||
return err
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue