mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Avoid system exit if only logging failed.
This commit is contained in:
parent
7cc1f473b6
commit
2a7972e8ea
|
@ -445,6 +445,10 @@ type loggingT struct {
|
||||||
// safely using atomic.LoadInt32.
|
// safely using atomic.LoadInt32.
|
||||||
vmodule moduleSpec // The state of the -vmodule flag.
|
vmodule moduleSpec // The state of the -vmodule flag.
|
||||||
verbosity Level // V logging level, the value of the -v flag/
|
verbosity Level // V logging level, the value of the -v flag/
|
||||||
|
|
||||||
|
// If the logging exits, the system should still run.
|
||||||
|
// This flag is to disable the logging if logging exited.
|
||||||
|
exited bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// buffer holds a byte Buffer for reuse. The zero value is ready for use.
|
// buffer holds a byte Buffer for reuse. The zero value is ready for use.
|
||||||
|
@ -743,7 +747,7 @@ func (l *loggingT) exit(err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
l.flushAll()
|
l.flushAll()
|
||||||
os.Exit(2)
|
l.exited = true // os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// syncBuffer joins a bufio.Writer to its underlying file, providing access to the
|
// syncBuffer joins a bufio.Writer to its underlying file, providing access to the
|
||||||
|
@ -763,6 +767,9 @@ func (sb *syncBuffer) Sync() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *syncBuffer) Write(p []byte) (n int, err error) {
|
func (sb *syncBuffer) Write(p []byte) (n int, err error) {
|
||||||
|
if sb.logger.exited {
|
||||||
|
return
|
||||||
|
}
|
||||||
if sb.nbytes+uint64(len(p)) >= MaxSize {
|
if sb.nbytes+uint64(len(p)) >= MaxSize {
|
||||||
if err := sb.rotateFile(time.Now()); err != nil {
|
if err := sb.rotateFile(time.Now()); err != nil {
|
||||||
sb.logger.exit(err)
|
sb.logger.exit(err)
|
||||||
|
|
Loading…
Reference in a new issue