Ensure log path is created on startup
This commit is contained in:
rodič
b4e7582a6d
revize
9cc910631d
10
options.go
10
options.go
|
@ -1,6 +1,11 @@
|
|||
package msgbus
|
||||
|
||||
import "github.com/tidwall/wal"
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/tidwall/wal"
|
||||
)
|
||||
|
||||
const (
|
||||
// DefaultBind is the default bind address
|
||||
|
@ -55,6 +60,9 @@ type Option func(opts *Options) error
|
|||
|
||||
func WithLogPath(logPath string) Option {
|
||||
return func(opts *Options) error {
|
||||
if err := os.MkdirAll(logPath, 0755); err != nil {
|
||||
return fmt.Errorf("error creating log path %s: %w", logPath, err)
|
||||
}
|
||||
opts.LogPath = logPath
|
||||
return nil
|
||||
}
|
||||
|
|
Načítá se…
Odkázat v novém úkolu