From b9bdcd5f87f40a6e81e629d9b25faee99fa94848 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 24 Feb 2024 05:40:01 +0000 Subject: [PATCH] feat(cmd_all): create directories in `single_node` mode (#15176) (#15220) Co-authored-by: Noel Kwan <47273164+kwannoel@users.noreply.github.com> --- src/cmd_all/src/bin/risingwave.rs | 1 + src/cmd_all/src/single_node.rs | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/cmd_all/src/bin/risingwave.rs b/src/cmd_all/src/bin/risingwave.rs index 2c167fc1bdc20..e9173abefe1df 100644 --- a/src/cmd_all/src/bin/risingwave.rs +++ b/src/cmd_all/src/bin/risingwave.rs @@ -239,6 +239,7 @@ fn standalone(opts: StandaloneOpts) { /// high level options to standalone mode node-level options. /// We will start a standalone instance, with all nodes in the same process. fn single_node(opts: SingleNodeOpts) { + opts.create_store_directories().unwrap(); let opts = risingwave_cmd_all::map_single_node_opts_to_standalone_opts(&opts); let settings = risingwave_rt::LoggerSettings::from_opts(&opts) .with_target("risingwave_storage", Level::WARN) diff --git a/src/cmd_all/src/single_node.rs b/src/cmd_all/src/single_node.rs index 25dd9f2c6d4a2..0ea9cfc78c4de 100644 --- a/src/cmd_all/src/single_node.rs +++ b/src/cmd_all/src/single_node.rs @@ -14,6 +14,7 @@ use std::sync::LazyLock; +use anyhow::Result; use clap::Parser; use home::home_dir; use risingwave_common::config::{AsyncStackTraceOption, MetaBackend}; @@ -64,7 +65,7 @@ pub struct SingleNodeOpts { /// The store directory used by meta store and object store. #[clap(long, env = "RW_SINGLE_NODE_STORE_DIRECTORY")] - store_directory: Option, + pub store_directory: Option, /// The address of the meta node. #[clap(long, env = "RW_SINGLE_NODE_META_ADDR")] @@ -142,6 +143,7 @@ pub fn map_single_node_opts_to_standalone_opts(opts: &SingleNodeOpts) -> ParsedS } } +// Defaults impl SingleNodeOpts { fn default_frontend_opts() -> FrontendOpts { FrontendOpts { @@ -227,3 +229,15 @@ impl SingleNodeOpts { } } } + +impl SingleNodeOpts { + pub fn create_store_directories(&self) -> Result<()> { + let store_directory = self + .store_directory + .as_ref() + .unwrap_or_else(|| &*DEFAULT_STORE_DIRECTORY); + std::fs::create_dir_all(format!("{}/meta_store", store_directory))?; + std::fs::create_dir_all(format!("{}/state_store", store_directory))?; + Ok(()) + } +}