mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
keep track of services errors
So we can exit with the correct code if an error happen inside the services goroutines Fixes #143
This commit is contained in:
@@ -34,7 +34,9 @@ Please take a look at the usage below to customize the startup options`,
|
|||||||
}
|
}
|
||||||
if err := service.Start(); err == nil {
|
if err := service.Start(); err == nil {
|
||||||
service.Wait()
|
service.Wait()
|
||||||
os.Exit(0)
|
if service.Error == nil {
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ type Service struct {
|
|||||||
LogVerbose bool
|
LogVerbose bool
|
||||||
Profiler bool
|
Profiler bool
|
||||||
Shutdown chan bool
|
Shutdown chan bool
|
||||||
|
Error error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start initializes the service
|
// Start initializes the service
|
||||||
@@ -92,6 +93,7 @@ func (s *Service) Start() error {
|
|||||||
if err := sftpdConf.Initialize(s.ConfigDir); err != nil {
|
if err := sftpdConf.Initialize(s.ConfigDir); err != nil {
|
||||||
logger.Error(logSender, "", "could not start SFTP server: %v", err)
|
logger.Error(logSender, "", "could not start SFTP server: %v", err)
|
||||||
logger.ErrorToConsole("could not start SFTP server: %v", err)
|
logger.ErrorToConsole("could not start SFTP server: %v", err)
|
||||||
|
s.Error = err
|
||||||
}
|
}
|
||||||
s.Shutdown <- true
|
s.Shutdown <- true
|
||||||
}()
|
}()
|
||||||
@@ -101,6 +103,7 @@ func (s *Service) Start() error {
|
|||||||
if err := httpdConf.Initialize(s.ConfigDir, s.Profiler); err != nil {
|
if err := httpdConf.Initialize(s.ConfigDir, s.Profiler); err != nil {
|
||||||
logger.Error(logSender, "", "could not start HTTP server: %v", err)
|
logger.Error(logSender, "", "could not start HTTP server: %v", err)
|
||||||
logger.ErrorToConsole("could not start HTTP server: %v", err)
|
logger.ErrorToConsole("could not start HTTP server: %v", err)
|
||||||
|
s.Error = err
|
||||||
}
|
}
|
||||||
s.Shutdown <- true
|
s.Shutdown <- true
|
||||||
}()
|
}()
|
||||||
|
|||||||
Reference in New Issue
Block a user