Compare commits
2 Commits
main
...
rf/bunfigR
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
deff6f39d7 | ||
|
|
389fd1d18b |
@@ -1,3 +1,4 @@
|
|||||||
|
#[allow(dead_code)]
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use wasm_bindgen_test::wasm_bindgen_test;
|
use wasm_bindgen_test::wasm_bindgen_test;
|
||||||
use windmill_parser::{Arg, MainArgSignature, ObjectProperty, Typ};
|
use windmill_parser::{Arg, MainArgSignature, ObjectProperty, Typ};
|
||||||
|
|||||||
@@ -800,10 +800,20 @@ Windmill Community Edition {GIT_VERSION}
|
|||||||
reload_instance_python_version_setting(&db).await
|
reload_instance_python_version_setting(&db).await
|
||||||
},
|
},
|
||||||
NPM_CONFIG_REGISTRY_SETTING => {
|
NPM_CONFIG_REGISTRY_SETTING => {
|
||||||
reload_npm_config_registry_setting(&db).await
|
if worker_mode {
|
||||||
|
tracing::info!("NPM config registry setting changed, restarting");
|
||||||
|
send_delayed_killpill(&tx, 5, "npm config registry setting change").await;
|
||||||
|
} else {
|
||||||
|
reload_npm_config_registry_setting(&db).await
|
||||||
|
}
|
||||||
},
|
},
|
||||||
BUNFIG_INSTALL_SCOPES_SETTING => {
|
BUNFIG_INSTALL_SCOPES_SETTING => {
|
||||||
reload_bunfig_install_scopes_setting(&db).await
|
if worker_mode {
|
||||||
|
tracing::info!("Bunfig install scopes setting changed, restarting");
|
||||||
|
send_delayed_killpill(&tx, 5, "bunfig install scopes setting change").await;
|
||||||
|
} else {
|
||||||
|
reload_bunfig_install_scopes_setting(&db).await
|
||||||
|
}
|
||||||
},
|
},
|
||||||
NUGET_CONFIG_SETTING => {
|
NUGET_CONFIG_SETTING => {
|
||||||
reload_nuget_config_setting(&db).await
|
reload_nuget_config_setting(&db).await
|
||||||
|
|||||||
@@ -107,13 +107,13 @@ pub async fn gen_bun_lockfile(
|
|||||||
raw_deps: Option<String>,
|
raw_deps: Option<String>,
|
||||||
npm_mode: bool,
|
npm_mode: bool,
|
||||||
occupancy_metrics: &mut Option<&mut OccupancyMetrics>,
|
occupancy_metrics: &mut Option<&mut OccupancyMetrics>,
|
||||||
|
has_bunfig: bool,
|
||||||
) -> Result<Option<String>> {
|
) -> Result<Option<String>> {
|
||||||
let common_bun_proc_envs: HashMap<String, String> = get_common_bun_proc_envs(None).await;
|
let common_bun_proc_envs: HashMap<String, String> = get_common_bun_proc_envs(None).await;
|
||||||
|
|
||||||
let mut empty_deps = false;
|
let mut empty_deps = false;
|
||||||
|
|
||||||
if let Some(raw_deps) = raw_deps {
|
if let Some(raw_deps) = raw_deps {
|
||||||
gen_bunfig(job_dir).await?;
|
|
||||||
write_file(job_dir, "package.json", raw_deps.as_str())?;
|
write_file(job_dir, "package.json", raw_deps.as_str())?;
|
||||||
} else {
|
} else {
|
||||||
let _ = write_file(
|
let _ = write_file(
|
||||||
@@ -137,8 +137,6 @@ pub async fn gen_bun_lockfile(
|
|||||||
),
|
),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
gen_bunfig(job_dir).await?;
|
|
||||||
|
|
||||||
let mut child_cmd = Command::new(&*BUN_PATH);
|
let mut child_cmd = Command::new(&*BUN_PATH);
|
||||||
child_cmd
|
child_cmd
|
||||||
.current_dir(job_dir)
|
.current_dir(job_dir)
|
||||||
@@ -192,6 +190,7 @@ pub async fn gen_bun_lockfile(
|
|||||||
common_bun_proc_envs,
|
common_bun_proc_envs,
|
||||||
npm_mode,
|
npm_mode,
|
||||||
occupancy_metrics,
|
occupancy_metrics,
|
||||||
|
has_bunfig,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
} else {
|
} else {
|
||||||
@@ -231,7 +230,7 @@ pub async fn gen_bun_lockfile(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn gen_bunfig(job_dir: &str) -> Result<()> {
|
pub async fn gen_bunfig(job_dir: &str) -> Result<bool> {
|
||||||
let registry = NPM_CONFIG_REGISTRY.read().await.clone();
|
let registry = NPM_CONFIG_REGISTRY.read().await.clone();
|
||||||
let bunfig_install_scopes = BUNFIG_INSTALL_SCOPES.read().await.clone();
|
let bunfig_install_scopes = BUNFIG_INSTALL_SCOPES.read().await.clone();
|
||||||
if registry.is_some() || bunfig_install_scopes.is_some() {
|
if registry.is_some() || bunfig_install_scopes.is_some() {
|
||||||
@@ -263,9 +262,11 @@ registry = {}
|
|||||||
.unwrap_or("".to_string())
|
.unwrap_or("".to_string())
|
||||||
);
|
);
|
||||||
tracing::debug!("Writing following bunfig.toml: {bunfig_toml}");
|
tracing::debug!("Writing following bunfig.toml: {bunfig_toml}");
|
||||||
let _ = write_file(&job_dir, "bunfig.toml", &bunfig_toml)?;
|
write_file(&job_dir, "bunfig.toml", &bunfig_toml)?;
|
||||||
|
Ok(true)
|
||||||
|
} else {
|
||||||
|
Ok(false)
|
||||||
}
|
}
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn install_bun_lockfile(
|
pub async fn install_bun_lockfile(
|
||||||
@@ -279,6 +280,7 @@ pub async fn install_bun_lockfile(
|
|||||||
common_bun_proc_envs: HashMap<String, String>,
|
common_bun_proc_envs: HashMap<String, String>,
|
||||||
npm_mode: bool,
|
npm_mode: bool,
|
||||||
occupancy_metrics: &mut Option<&mut OccupancyMetrics>,
|
occupancy_metrics: &mut Option<&mut OccupancyMetrics>,
|
||||||
|
has_bunfig: bool,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut child_cmd = Command::new(if npm_mode { &*NPM_PATH } else { &*BUN_PATH });
|
let mut child_cmd = Command::new(if npm_mode { &*NPM_PATH } else { &*BUN_PATH });
|
||||||
child_cmd
|
child_cmd
|
||||||
@@ -799,6 +801,7 @@ pub async fn handle_bun_job(
|
|||||||
shared_mount: &str,
|
shared_mount: &str,
|
||||||
new_args: &mut Option<HashMap<String, Box<RawValue>>>,
|
new_args: &mut Option<HashMap<String, Box<RawValue>>>,
|
||||||
occupancy_metrics: &mut OccupancyMetrics,
|
occupancy_metrics: &mut OccupancyMetrics,
|
||||||
|
has_bunfig: bool,
|
||||||
) -> error::Result<Box<RawValue>> {
|
) -> error::Result<Box<RawValue>> {
|
||||||
let mut annotation = windmill_common::worker::TypeScriptAnnotations::parse(inner_content);
|
let mut annotation = windmill_common::worker::TypeScriptAnnotations::parse(inner_content);
|
||||||
|
|
||||||
@@ -891,6 +894,7 @@ pub async fn handle_bun_job(
|
|||||||
common_bun_proc_envs.clone(),
|
common_bun_proc_envs.clone(),
|
||||||
annotation.npm,
|
annotation.npm,
|
||||||
&mut Some(occupancy_metrics),
|
&mut Some(occupancy_metrics),
|
||||||
|
has_bunfig,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
@@ -913,6 +917,7 @@ pub async fn handle_bun_job(
|
|||||||
None,
|
None,
|
||||||
annotation.npm,
|
annotation.npm,
|
||||||
&mut Some(occupancy_metrics),
|
&mut Some(occupancy_metrics),
|
||||||
|
has_bunfig,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
@@ -1545,6 +1550,7 @@ pub async fn start_worker(
|
|||||||
common_bun_proc_envs.clone(),
|
common_bun_proc_envs.clone(),
|
||||||
annotation.npm,
|
annotation.npm,
|
||||||
&mut None,
|
&mut None,
|
||||||
|
has_bunfig,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
tracing::info!("dedicated worker requirements installed: {reqs}");
|
tracing::info!("dedicated worker requirements installed: {reqs}");
|
||||||
@@ -1566,6 +1572,7 @@ pub async fn start_worker(
|
|||||||
None,
|
None,
|
||||||
annotation.npm,
|
annotation.npm,
|
||||||
&mut None,
|
&mut None,
|
||||||
|
has_bunfig,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -822,13 +822,18 @@ pub async fn run_worker(
|
|||||||
.expect("could not create initial worker dir");
|
.expect("could not create initial worker dir");
|
||||||
|
|
||||||
if !*DISABLE_NSJAIL {
|
if !*DISABLE_NSJAIL {
|
||||||
let _ = write_file(
|
write_file(
|
||||||
&worker_dir,
|
&worker_dir,
|
||||||
"download_deps.py.sh",
|
"download_deps.py.sh",
|
||||||
INCLUDE_DEPS_PY_SH_CONTENT,
|
INCLUDE_DEPS_PY_SH_CONTENT,
|
||||||
);
|
)
|
||||||
|
.map_err(|e| anyhow::anyhow!("Failed to write download_deps.py.sh: {e}"))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let has_bunfig = crate::bun_executor::gen_bunfig(&worker_dir)
|
||||||
|
.await
|
||||||
|
.map_err(|e| anyhow::anyhow!("Failed to generate bunfig: {e}"))?;
|
||||||
|
|
||||||
let mut last_ping = Instant::now() - Duration::from_secs(NUM_SECS_PING + 1);
|
let mut last_ping = Instant::now() - Duration::from_secs(NUM_SECS_PING + 1);
|
||||||
|
|
||||||
update_ping(hostname, &worker_name, ip, db).await;
|
update_ping(hostname, &worker_name, ip, db).await;
|
||||||
@@ -2723,6 +2728,7 @@ mount {{
|
|||||||
&shared_mount,
|
&shared_mount,
|
||||||
new_args,
|
new_args,
|
||||||
occupancy_metrics,
|
occupancy_metrics,
|
||||||
|
has_bunfig,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user