diff --git a/cassandra/src/helpers.rs b/cassandra/src/helpers.rs index c432117..0a65c95 100644 --- a/cassandra/src/helpers.rs +++ b/cassandra/src/helpers.rs @@ -25,6 +25,7 @@ pub fn setup() -> Result { let pwd = dag().get_env("PWD")?; let cassandra_port = dag().get_env("CASSANDRA_PORT")?; let data_dir = dag().get_env("CASSANDRA_DATADIR")?; + let cluster_name = dag().get_env("CASSANDRA_CLUSTER_NAME")?; if cassandra_port.is_empty() { dag().set_envs(vec![("CASSANDRA_PORT".into(), "7000".into())])?; @@ -37,17 +38,31 @@ pub fn setup() -> Result { )])?; } + if cluster_name.is_empty() { + dag().set_envs(vec![( + "CASSANDRA_CLUSTER_NAME".into(), + "Test Cluster".into(), + )])?; + } + dag().set_envs(vec![( "CASSANDRA_CONFIG".into(), format!("{}/cassandra.yaml", pwd), )])?; + let data_dir = dag().get_env("CASSANDRA_DATADIR")?; + dag().set_envs(vec![( + "CASSANDRA_LOG_DIR".into(), + format!("{}/logs", data_dir), + )])?; + let stdout = dag() .flox()? .with_workdir(".fluentci/cassandra")? .with_exec(vec![ "[ -d $CASSANDRA_DATADIR ] || mkdir -p $CASSANDRA_DATADIR", ])? + .with_exec(vec!["mkdir", "-p", "$CASSANDRA_LOG_DIR"])? .with_exec(vec!["flox", "install", "cassandra_4", "overmind", "tmux"])? .with_exec(vec!["[ -f cassandra.yaml.template ] || pkgx wget https://raw.githubusercontent.com/fluentci-io/services/main/cassandra/cassandra.yaml.template"])? .with_exec(vec!["[ -f $CASSANDRA_CONFIG ] || pkgx envsubst < cassandra.yaml.template > $CASSANDRA_CONFIG "])? diff --git a/cassandra/src/lib.rs b/cassandra/src/lib.rs index 158630c..c347e19 100644 --- a/cassandra/src/lib.rs +++ b/cassandra/src/lib.rs @@ -20,7 +20,7 @@ pub fn start(_args: String) -> FnResult { "echo -e \"Cassandra starting on port $CASSANDRA_PORT\"", ])? .with_exec(vec![ - "overmind start -f Procfile --daemonize || flox activate -- overmind restart cassandra", + "overmind start -f Procfile || flox activate -- overmind restart cassandra", ])? .wait_on(port.parse()?, None)? .with_exec(vec!["overmind", "status"])?