mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-25 16:02:11 +00:00
fix: flow picker of flows + precache hub scripts as bundles
This commit is contained in:
+23
-3
@@ -135,6 +135,7 @@ async fn cache_hub_scripts(file_path: Option<String>) -> anyhow::Result<()> {
|
||||
})?;
|
||||
|
||||
create_dir_all(HUB_CACHE_DIR).await?;
|
||||
create_dir_all(BUN_BUNDLE_CACHE_DIR).await?;
|
||||
|
||||
for path in paths.values() {
|
||||
tracing::info!("Caching hub script at {path}");
|
||||
@@ -166,7 +167,7 @@ async fn cache_hub_scripts(file_path: Option<String>) -> anyhow::Result<()> {
|
||||
create_dir_all(&job_dir).await?;
|
||||
if let Some(lockfile) = res.lockfile {
|
||||
let _ = windmill_worker::prepare_job_dir(&lockfile, &job_dir).await?;
|
||||
|
||||
let envs = windmill_worker::get_common_bun_proc_envs(None).await;
|
||||
let _ = windmill_worker::install_bun_lockfile(
|
||||
&mut 0,
|
||||
&mut None,
|
||||
@@ -175,11 +176,31 @@ async fn cache_hub_scripts(file_path: Option<String>) -> anyhow::Result<()> {
|
||||
None,
|
||||
&job_dir,
|
||||
"cache_init",
|
||||
windmill_worker::get_common_bun_proc_envs(None).await,
|
||||
envs.clone(),
|
||||
false,
|
||||
&mut None,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let _ = windmill_common::worker::write_file(&job_dir, "main.js", &res.content)?;
|
||||
|
||||
if let Err(e) = windmill_worker::prebundle_bun_script(
|
||||
&res.content,
|
||||
Some(lockfile),
|
||||
&path,
|
||||
&job_id,
|
||||
"admins",
|
||||
None,
|
||||
&job_dir,
|
||||
"",
|
||||
"cache_init",
|
||||
"",
|
||||
&mut None,
|
||||
)
|
||||
.await
|
||||
{
|
||||
panic!("Error prebundling bun script: {e:#}");
|
||||
}
|
||||
} else {
|
||||
tracing::warn!("No lockfile found for bun script {path}, skipping...");
|
||||
}
|
||||
@@ -339,7 +360,6 @@ async fn windmill_main() -> anyhow::Result<()> {
|
||||
config
|
||||
});
|
||||
|
||||
|
||||
tracing::info!("Connecting to database...");
|
||||
let db = windmill_common::connect_db(server_mode, indexer_mode).await?;
|
||||
tracing::info!("Database connected");
|
||||
|
||||
@@ -506,7 +506,7 @@ pub async fn generate_bun_bundle(
|
||||
mem_peak: &mut i32,
|
||||
canceled_by: &mut Option<CanceledBy>,
|
||||
common_bun_proc_envs: &HashMap<String, String>,
|
||||
occupancy_metrics: &mut OccupancyMetrics,
|
||||
occupancy_metrics: &mut Option<&mut OccupancyMetrics>,
|
||||
) -> Result<()> {
|
||||
let mut child = Command::new(&*BUN_PATH);
|
||||
child
|
||||
@@ -535,7 +535,7 @@ pub async fn generate_bun_bundle(
|
||||
"bun build",
|
||||
timeout,
|
||||
false,
|
||||
&mut Some(occupancy_metrics),
|
||||
occupancy_metrics,
|
||||
)
|
||||
.await?;
|
||||
} else {
|
||||
@@ -650,7 +650,7 @@ pub async fn prebundle_bun_script(
|
||||
base_internal_url: &str,
|
||||
worker_name: &str,
|
||||
token: &str,
|
||||
occupancy_metrics: &mut OccupancyMetrics,
|
||||
occupancy_metrics: &mut Option<&mut OccupancyMetrics>,
|
||||
) -> Result<()> {
|
||||
let (local_path, remote_path) = compute_bundle_local_and_remote_path(
|
||||
inner_content,
|
||||
@@ -1190,7 +1190,7 @@ try {{
|
||||
mem_peak,
|
||||
canceled_by,
|
||||
&common_bun_proc_envs,
|
||||
occupancy_metrics,
|
||||
&mut Some(occupancy_metrics),
|
||||
)
|
||||
.await?;
|
||||
if !local_path.is_empty() {
|
||||
|
||||
@@ -34,5 +34,7 @@ pub use worker::*;
|
||||
|
||||
pub use result_processor::handle_job_error;
|
||||
|
||||
pub use bun_executor::{get_common_bun_proc_envs, install_bun_lockfile, prepare_job_dir};
|
||||
pub use bun_executor::{
|
||||
get_common_bun_proc_envs, install_bun_lockfile, prebundle_bun_script, prepare_job_dir,
|
||||
};
|
||||
pub use deno_executor::generate_deno_lock;
|
||||
|
||||
@@ -1475,7 +1475,7 @@ async fn capture_dependency_job(
|
||||
base_internal_url,
|
||||
worker_name,
|
||||
&token,
|
||||
occupancy_metrics,
|
||||
&mut Some(occupancy_metrics),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,11 @@
|
||||
? 'bg-surface-hover'
|
||||
: ''}"
|
||||
on:click={() => {
|
||||
dispatch('pickScript', { path, hash: lockHash ? hash : undefined })
|
||||
if (kind == 'flow') {
|
||||
dispatch('pickFlow', { path: path })
|
||||
} else {
|
||||
dispatch('pickScript', { path: path, hash: lockHash ? hash : undefined })
|
||||
}
|
||||
}}
|
||||
>
|
||||
{#if kind == 'flow'}
|
||||
|
||||
Reference in New Issue
Block a user