JoinIR/SSA/Stage-3: sync CURRENT_TASK and dev env
This commit is contained in:
@ -422,7 +422,40 @@ pub fn get_global_plugin_host() -> Arc<RwLock<PluginHost>> {
|
||||
|
||||
pub fn init_global_plugin_host(config_path: &str) -> BidResult<()> {
|
||||
let host = get_global_plugin_host();
|
||||
host.write().unwrap().load_libraries(config_path)?;
|
||||
host.read().unwrap().register_boxes()?;
|
||||
{
|
||||
let mut h = host.write().unwrap();
|
||||
let disabled = std::env::var("NYASH_DISABLE_PLUGINS")
|
||||
.ok()
|
||||
.as_deref()
|
||||
.map(|v| v == "1" || v.eq_ignore_ascii_case("true") || v.eq_ignore_ascii_case("on"))
|
||||
.unwrap_or(false);
|
||||
if disabled {
|
||||
eprintln!("[plugin/init] plugins disabled by NYASH_DISABLE_PLUGINS=1");
|
||||
return Err(BidError::PluginError);
|
||||
}
|
||||
|
||||
if !std::path::Path::new(config_path).exists() {
|
||||
eprintln!(
|
||||
"[plugin/init] plugins disabled (config={}): config file not found",
|
||||
config_path
|
||||
);
|
||||
return Err(BidError::PluginError);
|
||||
}
|
||||
|
||||
h.load_libraries(config_path).map_err(|e| {
|
||||
eprintln!(
|
||||
"[plugin/init] load_libraries({}) failed: {}",
|
||||
config_path, e
|
||||
);
|
||||
BidError::PluginError
|
||||
})?;
|
||||
h.register_boxes().map_err(|e| {
|
||||
eprintln!(
|
||||
"[plugin/init] register_boxes({}) failed: {}",
|
||||
config_path, e
|
||||
);
|
||||
BidError::PluginError
|
||||
})?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -7,8 +7,10 @@ pub(super) fn load_config(loader: &mut PluginLoaderV2, config_path: &str) -> Bid
|
||||
.unwrap_or_else(|_| config_path.to_string());
|
||||
loader.config_path = Some(canonical.clone());
|
||||
loader.config = Some(
|
||||
crate::config::nyash_toml_v2::NyashConfigV2::from_file(&canonical)
|
||||
.map_err(|_| BidError::PluginError)?,
|
||||
crate::config::nyash_toml_v2::NyashConfigV2::from_file(&canonical).map_err(|e| {
|
||||
eprintln!("[plugin/init] failed to parse {}: {}", canonical, e);
|
||||
BidError::PluginError
|
||||
})?,
|
||||
);
|
||||
if let Some(cfg) = loader.config.as_ref() {
|
||||
let mut labels: Vec<String> = Vec::new();
|
||||
|
||||
@ -51,7 +51,15 @@ pub(super) fn load_plugin(
|
||||
lib_path.display()
|
||||
);
|
||||
}
|
||||
let lib = unsafe { Library::new(&lib_path) }.map_err(|_| BidError::PluginError)?;
|
||||
let lib = unsafe { Library::new(&lib_path) }.map_err(|e| {
|
||||
eprintln!(
|
||||
"[plugin/init] dlopen failed for {} ({}): {}",
|
||||
lib_name,
|
||||
lib_path.display(),
|
||||
e
|
||||
);
|
||||
BidError::PluginError
|
||||
})?;
|
||||
let lib_arc = Arc::new(lib);
|
||||
|
||||
unsafe {
|
||||
|
||||
Reference in New Issue
Block a user