From ee451cbd950f82abf1df3d5e49ad74fbe9a53aa8 Mon Sep 17 00:00:00 2001 From: Keuin Date: Thu, 8 Sep 2022 03:33:41 +0800 Subject: Add watch restart sleep. --- main.go | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index db58eca..51350b5 100644 --- a/main.go +++ b/main.go @@ -48,8 +48,18 @@ func getTasks() (tasks []recording.TaskConfig) { &argparse.Options{ Required: false, Help: "Specify which configuration file to use", + Default: ".", }, ) + diskBufSizePtr := parser.Int( + "b", "disk-write-buffer", + &argparse.Options{ + Required: false, + Help: "Specify disk write buffer size (bytes). The real minimum buffer size is determined by OS.", + Default: -1, + }, + ) + err = parser.Parse(os.Args) if err != nil { return @@ -71,13 +81,15 @@ func getTasks() (tasks []recording.TaskConfig) { if fromFile { configFile := *configFilePtr fmt.Printf("Config file: %v\n", configFile) - var file *os.File - file, err = os.Open(configFile) + + viper.SetConfigFile(configFile) + + err = viper.ReadInConfig() if err != nil { err = fmt.Errorf("cannot open config file \"%v\": %w", configFile, err) return } - err = viper.ReadConfig(file) + if err != nil { err = fmt.Errorf("cannot read config file \"%v\": %w", configFile, err) return @@ -95,13 +107,15 @@ func getTasks() (tasks []recording.TaskConfig) { // generate task list from cli taskCount := len(*rooms) tasks = make([]recording.TaskConfig, taskCount) - saveTo := common.Zeroable[string](*saveToPtr).OrElse(".") + saveTo := *saveToPtr + diskBufSize := *diskBufSizePtr for i := 0; i < taskCount; i++ { tasks[i] = recording.TaskConfig{ RoomId: common.RoomId((*rooms)[i]), Transport: recording.DefaultTransportConfig(), Download: recording.DownloadConfig{ - SaveDirectory: saveTo, + DiskWriteBufferBytes: diskBufSize, + SaveDirectory: saveTo, }, } } -- cgit v1.2.3