Merge pull request #2039 from influxdb/panic_home_dir
Don't panic if getting current use failspull/2040/head
commit
259f0aacad
|
@ -2,6 +2,7 @@
|
|||
|
||||
## Bugfixes
|
||||
- [#2037](https://github.com/influxdb/influxdb/pull/2037) Don't check 'configExists' at Run() level
|
||||
- [#2039](https://github.com/influxdb/influxdb/pull/2039) Don't panic if getting current use fails
|
||||
|
||||
## v0.9.0-rc15 [2015-03-19]
|
||||
|
||||
|
|
|
@ -152,8 +152,11 @@ type Config struct {
|
|||
}
|
||||
|
||||
// NewConfig returns an instance of Config with reasonable defaults.
|
||||
func NewConfig() *Config {
|
||||
u, _ := user.Current()
|
||||
func NewConfig() (*Config, error) {
|
||||
u, err := user.Current()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to determine current user for storage")
|
||||
}
|
||||
|
||||
c := &Config{}
|
||||
c.Broker.Dir = filepath.Join(u.HomeDir, ".influxdb/broker")
|
||||
|
@ -191,7 +194,7 @@ func NewConfig() *Config {
|
|||
// Port: tomlConfiguration.InputPlugins.UDPInput.Port,
|
||||
// })
|
||||
|
||||
return c
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// DataAddr returns the TCP binding address for the data server.
|
||||
|
@ -320,7 +323,10 @@ func (d *Duration) UnmarshalText(text []byte) error {
|
|||
|
||||
// ParseConfigFile parses a configuration file at a given path.
|
||||
func ParseConfigFile(path string) (*Config, error) {
|
||||
c := NewConfig()
|
||||
c, err := NewConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := toml.DecodeFile(path, &c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -329,7 +335,10 @@ func ParseConfigFile(path string) (*Config, error) {
|
|||
|
||||
// ParseConfig parses a configuration string into a config object.
|
||||
func ParseConfig(s string) (*Config, error) {
|
||||
c := NewConfig()
|
||||
c, err := NewConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := toml.Decode(s, &c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -230,7 +230,12 @@ func writePIDFile(path string) {
|
|||
// parses the configuration from a given path. Sets overrides as needed.
|
||||
func parseConfig(path, hostname string) *Config {
|
||||
if path == "" {
|
||||
return NewConfig()
|
||||
c, err := NewConfig()
|
||||
if err != nil {
|
||||
log.Fatalf("failed to generate default config: %s. Please supply an explicit configuration file",
|
||||
err.Error())
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
// Parse configuration.
|
||||
|
@ -264,6 +269,7 @@ func openBroker(path string, u url.URL, initializing bool, joinURLs []url.URL, w
|
|||
if err := b.Open(path); err != nil {
|
||||
log.Fatalf("failed to open broker at %s : %s", path, err)
|
||||
}
|
||||
log.Printf("broker opened at %s", path)
|
||||
|
||||
// Attach the broker as the finite state machine of the raft log.
|
||||
l.FSM = &messaging.RaftFSM{Broker: b}
|
||||
|
@ -342,6 +348,7 @@ func openServer(config *Config, b *influxdb.Broker, initServer, initBroker bool,
|
|||
if err := s.Open(config.Data.Dir, c); err != nil {
|
||||
log.Fatalf("failed to open data server: %v", err.Error())
|
||||
}
|
||||
log.Printf("data server opened at %s", config.Data.Dir)
|
||||
|
||||
// If the server is uninitialized then initialize or join it.
|
||||
if initServer {
|
||||
|
|
|
@ -90,7 +90,7 @@ func createCombinedNodeCluster(t *testing.T, testName, tmpDir string, nNodes, ba
|
|||
// Create the first node, special case.
|
||||
c := baseConfig
|
||||
if c == nil {
|
||||
c = main.NewConfig()
|
||||
c, _ = main.NewConfig()
|
||||
}
|
||||
c.Broker.Dir = filepath.Join(tmpBrokerDir, strconv.Itoa(basePort))
|
||||
c.Data.Dir = filepath.Join(tmpDataDir, strconv.Itoa(basePort))
|
||||
|
@ -1189,7 +1189,7 @@ func Test_ServerSingleGraphiteIntegration(t *testing.T) {
|
|||
testName := "graphite integration"
|
||||
dir := tempfile()
|
||||
now := time.Now().UTC().Round(time.Millisecond)
|
||||
c := main.NewConfig()
|
||||
c, _ := main.NewConfig()
|
||||
g := main.Graphite{
|
||||
Enabled: true,
|
||||
Database: "graphite",
|
||||
|
@ -1239,7 +1239,7 @@ func Test_ServerSingleGraphiteIntegration_ZeroDataPoint(t *testing.T) {
|
|||
testName := "graphite integration"
|
||||
dir := tempfile()
|
||||
now := time.Now().UTC().Round(time.Millisecond)
|
||||
c := main.NewConfig()
|
||||
c, _ := main.NewConfig()
|
||||
g := main.Graphite{
|
||||
Enabled: true,
|
||||
Database: "graphite",
|
||||
|
@ -1290,7 +1290,7 @@ func Test_ServerSingleGraphiteIntegration_NoDatabase(t *testing.T) {
|
|||
testName := "graphite integration"
|
||||
dir := tempfile()
|
||||
now := time.Now().UTC().Round(time.Millisecond)
|
||||
c := main.NewConfig()
|
||||
c, _ := main.NewConfig()
|
||||
g := main.Graphite{
|
||||
Enabled: true,
|
||||
Port: 2203,
|
||||
|
|
Loading…
Reference in New Issue