-
Notifications
You must be signed in to change notification settings - Fork 22
feat: dev/prod node isolation — lockfile, --dev flag, network modes, production build flag #780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
23e7b02
e3c61a9
3ea31a7
b30cf76
da1c25a
77db873
3455b12
958b8e0
f725cf9
589e374
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -140,6 +140,12 @@ enum Domain { | |||||||||||||||||||
| /// Useful for test harnesses that need targeted process cleanup. | ||||||||||||||||||||
| #[arg(long)] | ||||||||||||||||||||
| pid_file: Option<String>, | ||||||||||||||||||||
| /// Run in development mode (data: ~/.ad4m-dev, network: devnet, log: debug) | ||||||||||||||||||||
| #[arg(long, action)] | ||||||||||||||||||||
| dev: bool, | ||||||||||||||||||||
| /// Network mode: mainnet (default), devnet, or local | ||||||||||||||||||||
| #[arg(long)] | ||||||||||||||||||||
| network_mode: Option<String>, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| RunLocalHcServices {}, | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
@@ -169,19 +175,19 @@ async fn main() -> Result<()> { | |||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if let Domain::Run { | ||||||||||||||||||||
| app_data_path, | ||||||||||||||||||||
| network_bootstrap_seed, | ||||||||||||||||||||
| mut app_data_path, | ||||||||||||||||||||
| mut network_bootstrap_seed, | ||||||||||||||||||||
| language_language_only, | ||||||||||||||||||||
| run_dapp_server, | ||||||||||||||||||||
| gql_port, | ||||||||||||||||||||
| hc_admin_port, | ||||||||||||||||||||
| hc_app_port, | ||||||||||||||||||||
| hc_use_bootstrap, | ||||||||||||||||||||
| mut hc_use_bootstrap, | ||||||||||||||||||||
| hc_use_local_proxy, | ||||||||||||||||||||
| hc_use_mdns, | ||||||||||||||||||||
| mut hc_use_mdns, | ||||||||||||||||||||
| hc_use_proxy, | ||||||||||||||||||||
| hc_proxy_url, | ||||||||||||||||||||
| hc_bootstrap_url, | ||||||||||||||||||||
| mut hc_proxy_url, | ||||||||||||||||||||
| mut hc_bootstrap_url, | ||||||||||||||||||||
|
Comment on lines
+185
to
+190
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Local mode doesn't fully force proxy discovery off.
💡 Suggested change@@
- hc_use_local_proxy,
+ mut hc_use_local_proxy,
@@
- hc_use_proxy,
+ mut hc_use_proxy,
@@
NetworkMode::Local => {
hc_use_mdns = Some(true);
hc_use_bootstrap = Some(false);
+ hc_use_proxy = Some(false);
+ hc_use_local_proxy = Some(false);
hc_proxy_url = Some(String::new());
hc_bootstrap_url = Some(String::new());
}Also applies to: 237-243 🤖 Prompt for AI Agents |
||||||||||||||||||||
| hc_relay_url, | ||||||||||||||||||||
| connect_holochain, | ||||||||||||||||||||
| admin_credential, | ||||||||||||||||||||
|
|
@@ -194,8 +200,75 @@ async fn main() -> Result<()> { | |||||||||||||||||||
| enable_mcp, | ||||||||||||||||||||
| mcp_port, | ||||||||||||||||||||
| pid_file, | ||||||||||||||||||||
| dev, | ||||||||||||||||||||
| network_mode, | ||||||||||||||||||||
| } = args.domain | ||||||||||||||||||||
| { | ||||||||||||||||||||
| use rust_executor::config::NetworkMode; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Refuse --dev in production builds | ||||||||||||||||||||
| if rust_executor::globals::IS_PRODUCTION_BUILD && dev { | ||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? I hardly use dev builds because of the 100GBs for cargo artefacts and no GPU accelleration. So I would want to use this feature with a release build.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah just read below that this does not equal release built, but there is a special production feature flag... ok. |
||||||||||||||||||||
| eprintln!("ERROR: Cannot use --dev with production builds"); | ||||||||||||||||||||
| std::process::exit(1); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Parse network mode | ||||||||||||||||||||
| let network_mode: NetworkMode = if let Some(ref mode_str) = network_mode { | ||||||||||||||||||||
| mode_str.parse().unwrap_or_else(|_| { | ||||||||||||||||||||
| eprintln!( | ||||||||||||||||||||
| "ERROR: Invalid network mode '{}'. Use: mainnet, devnet, local", | ||||||||||||||||||||
| mode_str | ||||||||||||||||||||
| ); | ||||||||||||||||||||
| std::process::exit(1); | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| } else if dev { | ||||||||||||||||||||
| NetworkMode::Devnet | ||||||||||||||||||||
| } else { | ||||||||||||||||||||
| NetworkMode::Mainnet | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Apply --dev defaults | ||||||||||||||||||||
| if dev && app_data_path.is_none() { | ||||||||||||||||||||
| let home = dirs::home_dir().expect("Could not get home directory"); | ||||||||||||||||||||
| app_data_path = Some(home.join(".ad4m-dev").to_string_lossy().into_owned()); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+231
to
+234
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
These defaults are keyed off 💡 Suggested change- // Apply --dev defaults
- if dev && app_data_path.is_none() {
+ // Apply dev/devnet defaults
+ if app_data_path.is_none() && (dev || network_mode == NetworkMode::Devnet) {
let home = dirs::home_dir().expect("Could not get home directory");
app_data_path = Some(home.join(".ad4m-dev").to_string_lossy().into_owned());
}Also applies to: 249-252 🤖 Prompt for AI Agents |
||||||||||||||||||||
|
|
||||||||||||||||||||
| // Apply network mode to config | ||||||||||||||||||||
| match network_mode { | ||||||||||||||||||||
| NetworkMode::Local => { | ||||||||||||||||||||
| hc_use_mdns = Some(true); | ||||||||||||||||||||
| hc_use_bootstrap = Some(false); | ||||||||||||||||||||
| hc_proxy_url = Some(String::new()); | ||||||||||||||||||||
| hc_bootstrap_url = Some(String::new()); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| _ => {} | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // For devnet mode, write devnet seed | ||||||||||||||||||||
| if network_mode == NetworkMode::Devnet && network_bootstrap_seed.is_none() { | ||||||||||||||||||||
| let data_path = app_data_path.clone().unwrap_or_else(|| { | ||||||||||||||||||||
| let home = dirs::home_dir().expect("Could not get home directory"); | ||||||||||||||||||||
| home.join(".ad4m").to_string_lossy().into_owned() | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| std::fs::create_dir_all(&data_path).ok(); | ||||||||||||||||||||
| let seed_path = std::path::PathBuf::from(&data_path).join("devnet_seed.seed"); | ||||||||||||||||||||
| std::fs::write(&seed_path, rust_executor::globals::DEVNET_JSON) | ||||||||||||||||||||
| .expect("Could not write devnet seed file"); | ||||||||||||||||||||
|
Comment on lines
+253
to
+256
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't discard
💡 Suggested change- std::fs::create_dir_all(&data_path).ok();
+ std::fs::create_dir_all(&data_path)
+ .expect("Could not create data directory for devnet seed");📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| network_bootstrap_seed = Some(seed_path.to_string_lossy().into_owned()); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if dev { | ||||||||||||||||||||
| eprintln!( | ||||||||||||||||||||
| "⚠️ DEVELOPMENT MODE — data: {} | network: {}", | ||||||||||||||||||||
| app_data_path.as_deref().unwrap_or("~/.ad4m-dev"), | ||||||||||||||||||||
| network_mode | ||||||||||||||||||||
| ); | ||||||||||||||||||||
| if std::env::var("RUST_LOG").is_err() { | ||||||||||||||||||||
| std::env::set_var("RUST_LOG", "debug"); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } else if !rust_executor::globals::IS_PRODUCTION_BUILD { | ||||||||||||||||||||
| eprintln!("[dev build] Use --dev for development mode defaults"); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| let tls = if tls_cert_file.is_some() && tls_key_file.is_some() { | ||||||||||||||||||||
| Some(TlsConfig { | ||||||||||||||||||||
| cert_file_path: tls_cert_file.unwrap(), | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -34,6 +34,7 @@ use ad4m_client::*; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use anyhow::{Context, Result}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use clap::{Parser, Subcommand}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use rust_executor::Ad4mConfig; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use rust_executor::config::NetworkMode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use startup::executor_data_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// AD4M command line interface. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -78,6 +79,10 @@ struct ClapApp { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Provide admin credential to gain all capabilities | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[arg(short, long)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| admin_credential: Option<String>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Data directory to read executor-port from (default: ~/.ad4m) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[arg(long)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data_path: Option<String>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[derive(Debug, Subcommand)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -166,6 +171,12 @@ enum Domain { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Write the executor PID to this file on startup (removed on clean shutdown). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[arg(long)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pid_file: Option<String>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Run in development mode (data: ~/.ad4m-dev, network: devnet, log: debug) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[arg(long, action)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev: bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Network mode: mainnet (default), devnet, or local | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[arg(long)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| network_mode: Option<String>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RunLocalHcServices {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Eve { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -178,7 +189,7 @@ async fn get_ad4m_client(args: &ClapApp) -> Result<Ad4mClient> { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let executor_url = if let Some(custom_url) = args.executor_url.clone() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| custom_url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| crate::startup::get_executor_url()? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| crate::startup::get_executor_url(args.data_path.as_deref())? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let cap_token = if let Some(admin_credential) = &args.admin_credential { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -247,8 +258,70 @@ async fn main() -> Result<()> { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| enable_mcp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mcp_port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pid_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| network_mode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } = args.domain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Validate production build constraints | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if rust_executor::globals::IS_PRODUCTION_BUILD && dev { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| eprintln!("ERROR: Cannot use --dev with production builds"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::process::exit(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Parse network mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let network_mode: NetworkMode = if let Some(ref mode_str) = network_mode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mode_str.parse().unwrap_or_else(|e: String| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| eprintln!("ERROR: {}", e); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::process::exit(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if dev { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NetworkMode::Devnet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NetworkMode::Mainnet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Apply --dev defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let app_data_path = if dev && app_data_path.is_none() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let home = dirs::home_dir().expect("Could not get home directory"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Some(home.join(".ad4m-dev").to_string_lossy().into_owned()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app_data_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Apply network mode to config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let (hc_use_mdns, hc_use_bootstrap, hc_use_proxy, hc_proxy_url, hc_bootstrap_url) = match network_mode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NetworkMode::Local => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (Some(true), Some(false), Some(false), Some(String::new()), Some(String::new())) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _ => (hc_use_mdns, hc_use_bootstrap, hc_use_proxy, hc_proxy_url, hc_bootstrap_url), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // For devnet mode, write devnet seed instead of mainnet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let network_bootstrap_seed = if network_mode == NetworkMode::Devnet && network_bootstrap_seed.is_none() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Will be handled in config.prepare() — write devnet seed file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let data_path = app_data_path.clone().unwrap_or_else(|| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let home = dirs::home_dir().expect("Could not get home directory"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| home.join(".ad4m").to_string_lossy().into_owned() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::fs::create_dir_all(&data_path).ok(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let seed_path = std::path::PathBuf::from(&data_path).join("devnet_seed.seed"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::fs::write(&seed_path, rust_executor::globals::DEVNET_JSON) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .expect("Could not write devnet seed file"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Some(seed_path.to_string_lossy().into_owned()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| network_bootstrap_seed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+283
to
+313
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When 💡 Suggested fix- let app_data_path = if dev && app_data_path.is_none() {
+ let app_data_path = if app_data_path.is_none()
+ && (dev || network_mode == NetworkMode::Devnet)
+ {
let home = dirs::home_dir().expect("Could not get home directory");
Some(home.join(".ad4m-dev").to_string_lossy().into_owned())
} else {
app_data_path
};
@@
- let data_path = app_data_path.clone().unwrap_or_else(|| {
- let home = dirs::home_dir().expect("Could not get home directory");
- home.join(".ad4m").to_string_lossy().into_owned()
- });
+ let data_path = app_data_path
+ .clone()
+ .expect("devnet should always resolve to an isolated data path");Please add a regression test for 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if dev { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| eprintln!("⚠️ DEVELOPMENT MODE — data: {} | network: {}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app_data_path.as_deref().unwrap_or("~/.ad4m-dev"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| network_mode); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Set RUST_LOG to debug if not already set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if std::env::var("RUST_LOG").is_err() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::env::set_var("RUST_LOG", "debug"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let _ = tokio::spawn(async move { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rust_executor::run(Ad4mConfig { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app_data_path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -348,6 +421,8 @@ async fn main() -> Result<()> { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| enable_mcp: _, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mcp_port: _, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pid_file: _, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev: _, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| network_mode: _, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } => unreachable!(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Domain::RunLocalHcServices {} => unreachable!(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Domain::Eve { command: _ } => unreachable!(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logstill ignores the selected instance path.--data-pathnow selects which executor directory to inspect forexecutor-port, butDomain::Logstill readsexecutor_data_path().join("ad4m.log")at Lines 163-169.ad4m --data-path ~/.ad4m-dev logwill therefore still show the default instance's log.Also applies to: 120-125
🤖 Prompt for AI Agents