diff --git a/cmd/example-posix/README.md b/cmd/example-posix/README.md index a9688094..36b66afd 100644 --- a/cmd/example-posix/README.md +++ b/cmd/example-posix/README.md @@ -5,7 +5,7 @@ This endpoint takes arbitrary data and adds it to a file-based log. ## Using in the hammer -First bring up a new log: +First bring up a new log in one terminal: ```shell export LOG_PRIVATE_KEY="PRIVATE+KEY+example.com/log/testdata+33d7b496+AeymY/SZAX0jZcJ8enZ5FY1Dz+wTML2yWSkK+9DSF3eg" export LOG_PUBLIC_KEY="example.com/log/testdata+33d7b496+AeHTu4Q3hEIMHNqc6fASMsq3rKNx280NI+oO5xCFkkSx" @@ -15,11 +15,11 @@ export LOG_DIR=/tmp/mylog2 go run ./cmd/example-posix \ --storage_dir=${LOG_DIR} \ --initialise \ - --listen=:2025 + --listen=:2025 \ --v=2 ``` -Then run the hammer against the log. +In another terminal, run the hammer against the log. In this example, we're running 32 writers against the log to add 128 new leaves within 1 minute. ```shell diff --git a/cmd/example-posix/main.go b/cmd/example-posix/main.go index 12b33303..c6b20077 100644 --- a/cmd/example-posix/main.go +++ b/cmd/example-posix/main.go @@ -100,8 +100,8 @@ func main() { return posix.WriteCheckpoint(*storageDir, n) } if *initialise { - if err := os.RemoveAll(*storageDir); err != nil { - klog.Exitf("Failed to remove existing contents from log directory %q: %v", *storageDir, err) + if files, err := os.ReadDir(*storageDir); err == nil && len(files) > 0 { + klog.Exitf("Cannot initialize a log at a non-empty directory") } if err := os.MkdirAll(*storageDir, dirPerm); err != nil { klog.Exitf("Failed to create log directory %q: %v", *storageDir, err)