Skip to content

Commit

Permalink
feat(cmd_all): create directories in single_node mode (#15176) (#15220
Browse files Browse the repository at this point in the history
)

Co-authored-by: Noel Kwan <[email protected]>
  • Loading branch information
github-actions[bot] and kwannoel authored Feb 24, 2024
1 parent aea6483 commit b9bdcd5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/cmd_all/src/bin/risingwave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 15 additions & 1 deletion src/cmd_all/src/single_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use std::sync::LazyLock;

use anyhow::Result;
use clap::Parser;
use home::home_dir;
use risingwave_common::config::{AsyncStackTraceOption, MetaBackend};
Expand Down Expand Up @@ -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<String>,
pub store_directory: Option<String>,

/// The address of the meta node.
#[clap(long, env = "RW_SINGLE_NODE_META_ADDR")]
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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(())
}
}

0 comments on commit b9bdcd5

Please sign in to comment.