Compare commits

...

2 Commits

Author SHA1 Message Date
Ruben Fiszel
deff6f39d7 all 2025-02-26 17:07:41 +01:00
Ruben Fiszel
389fd1d18b all 2025-02-26 13:56:51 +01:00
4 changed files with 34 additions and 10 deletions

View File

@@ -1,3 +1,4 @@
#[allow(dead_code)]
use serde_json::json;
use wasm_bindgen_test::wasm_bindgen_test;
use windmill_parser::{Arg, MainArgSignature, ObjectProperty, Typ};

View File

@@ -800,10 +800,20 @@ Windmill Community Edition {GIT_VERSION}
reload_instance_python_version_setting(&db).await
},
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 => {
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 => {
reload_nuget_config_setting(&db).await

View File

@@ -107,13 +107,13 @@ pub async fn gen_bun_lockfile(
raw_deps: Option<String>,
npm_mode: bool,
occupancy_metrics: &mut Option<&mut OccupancyMetrics>,
has_bunfig: bool,
) -> Result<Option<String>> {
let common_bun_proc_envs: HashMap<String, String> = get_common_bun_proc_envs(None).await;
let mut empty_deps = false;
if let Some(raw_deps) = raw_deps {
gen_bunfig(job_dir).await?;
write_file(job_dir, "package.json", raw_deps.as_str())?;
} else {
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);
child_cmd
.current_dir(job_dir)
@@ -192,6 +190,7 @@ pub async fn gen_bun_lockfile(
common_bun_proc_envs,
npm_mode,
occupancy_metrics,
has_bunfig,
)
.await?;
} 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 bunfig_install_scopes = BUNFIG_INSTALL_SCOPES.read().await.clone();
if registry.is_some() || bunfig_install_scopes.is_some() {
@@ -263,9 +262,11 @@ registry = {}
.unwrap_or("".to_string())
);
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(
@@ -279,6 +280,7 @@ pub async fn install_bun_lockfile(
common_bun_proc_envs: HashMap<String, String>,
npm_mode: bool,
occupancy_metrics: &mut Option<&mut OccupancyMetrics>,
has_bunfig: bool,
) -> Result<()> {
let mut child_cmd = Command::new(if npm_mode { &*NPM_PATH } else { &*BUN_PATH });
child_cmd
@@ -799,6 +801,7 @@ pub async fn handle_bun_job(
shared_mount: &str,
new_args: &mut Option<HashMap<String, Box<RawValue>>>,
occupancy_metrics: &mut OccupancyMetrics,
has_bunfig: bool,
) -> error::Result<Box<RawValue>> {
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(),
annotation.npm,
&mut Some(occupancy_metrics),
has_bunfig,
)
.await?;
}
@@ -913,6 +917,7 @@ pub async fn handle_bun_job(
None,
annotation.npm,
&mut Some(occupancy_metrics),
has_bunfig,
)
.await?;
@@ -1545,6 +1550,7 @@ pub async fn start_worker(
common_bun_proc_envs.clone(),
annotation.npm,
&mut None,
has_bunfig,
)
.await?;
tracing::info!("dedicated worker requirements installed: {reqs}");
@@ -1566,6 +1572,7 @@ pub async fn start_worker(
None,
annotation.npm,
&mut None,
has_bunfig,
)
.await?;
}

View File

@@ -822,13 +822,18 @@ pub async fn run_worker(
.expect("could not create initial worker dir");
if !*DISABLE_NSJAIL {
let _ = write_file(
write_file(
&worker_dir,
"download_deps.py.sh",
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);
update_ping(hostname, &worker_name, ip, db).await;
@@ -2723,6 +2728,7 @@ mount {{
&shared_mount,
new_args,
occupancy_metrics,
has_bunfig,
)
.await
}