mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
fix: return error from function LoadConfigFile to the caller
Signed-off-by: wuwenjia5 <wuwenjia5@jd.com>
This commit is contained in:
parent
4e573923f5
commit
c8b46cc021
@ -89,7 +89,11 @@ func main() {
|
||||
* LoadConfigFile should be checked before start daemon, since it will
|
||||
* call os.Exit() w/o notifying the parent process.
|
||||
*/
|
||||
cfg := config.LoadConfigFile(*configFile)
|
||||
cfg, err := config.LoadConfigFile(*configFile)
|
||||
if err != nil {
|
||||
daemonize.SignalOutcome(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if !*configForeground {
|
||||
if err := startDaemon(); err != nil {
|
||||
|
||||
@ -90,7 +90,11 @@ func main() {
|
||||
* LoadConfigFile should be checked before start daemon, since it will
|
||||
* call os.Exit() w/o notifying the parent process.
|
||||
*/
|
||||
cfg := config.LoadConfigFile(*configFile)
|
||||
cfg, err := config.LoadConfigFile(*configFile)
|
||||
if err != nil {
|
||||
daemonize.SignalOutcome(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if !*configForeground {
|
||||
if err := startDaemon(); err != nil {
|
||||
|
||||
@ -127,7 +127,11 @@ func main() {
|
||||
* LoadConfigFile should be checked before start daemon, since it will
|
||||
* call os.Exit() w/o notifying the parent process.
|
||||
*/
|
||||
cfg := config.LoadConfigFile(*configFile)
|
||||
cfg, err := config.LoadConfigFile(*configFile)
|
||||
if err != nil {
|
||||
daemonize.SignalOutcome(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if !*configForeground {
|
||||
if err := startDaemon(); err != nil {
|
||||
@ -185,7 +189,7 @@ func main() {
|
||||
level = log.ErrorLevel
|
||||
}
|
||||
|
||||
_, err := log.InitLog(logDir, module, level, nil)
|
||||
_, err = log.InitLog(logDir, module, level, nil)
|
||||
if err != nil {
|
||||
daemonize.SignalOutcome(fmt.Errorf("Fatal: failed to init log - %v", err))
|
||||
os.Exit(1)
|
||||
|
||||
@ -34,13 +34,13 @@ func newConfig() *Config {
|
||||
}
|
||||
|
||||
// LoadConfigFile loads config information from a JSON file.
|
||||
func LoadConfigFile(filename string) *Config {
|
||||
func LoadConfigFile(filename string) (*Config, error) {
|
||||
result := newConfig()
|
||||
err := result.parse(filename)
|
||||
if err != nil {
|
||||
log.Fatalf("error loading config file %s: %s", filename, err)
|
||||
log.Printf("error loading config file %s: %s", filename, err)
|
||||
}
|
||||
return result
|
||||
return result, err
|
||||
}
|
||||
|
||||
// LoadConfigString loads config information from a JSON string.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user