Page MenuHomeDevCentral

D4149.diff
No OneTemporary

D4149.diff

diff --git a/Cargo.toml b/Cargo.toml
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -25,5 +25,6 @@
version = "1.53.1"
features = [
"macros",
+ "process",
"rt-multi-thread",
]
diff --git a/src/actions.rs b/src/actions.rs
--- a/src/actions.rs
+++ b/src/actions.rs
@@ -25,7 +25,7 @@
// Actions available both for CLI and HTTP
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-fn run_deployment_action(
+async fn run_deployment_action(
site_name: &str,
context: Option<String>,
config: &AlkaneConfig,
@@ -46,7 +46,7 @@
DeployError::Alkane(error)
})?;
- let status = recipes.run_recipe(&site, action);
+ let status = recipes.run_recipe(&site, action).await;
if action == "init" && status == RecipeStatus::Success {
db.set_initialized(&site.name);
@@ -55,31 +55,31 @@
Ok(status)
}
-pub fn initialize(
+pub async fn initialize(
site_name: &str,
context: Option<String>,
config: &AlkaneConfig,
) -> Result<RecipeStatus, DeployError> {
- run_deployment_action(site_name, context, config, "init")
+ run_deployment_action(site_name, context, config, "init").await
}
-pub fn update(
+pub async fn update(
site_name: &str,
context: Option<String>,
config: &AlkaneConfig,
) -> Result<RecipeStatus, DeployError> {
- run_deployment_action(site_name, context, config, "update")
+ run_deployment_action(site_name, context, config, "update").await
}
-pub fn deploy(
+pub async fn deploy(
site_name: &str,
context: Option<String>,
config: &AlkaneConfig,
) -> Result<RecipeStatus, DeployError> {
if is_present(site_name, config) {
- run_deployment_action(site_name, context, config, "update")
+ run_deployment_action(site_name, context, config, "update").await
} else {
- run_deployment_action(site_name, context, config, "init")
+ run_deployment_action(site_name, context, config, "init").await
}
}
diff --git a/src/main.rs b/src/main.rs
--- a/src/main.rs
+++ b/src/main.rs
@@ -54,17 +54,17 @@
}
AlkaneCommand::Update(args) => {
- let result = update(&args.site_name, None, &config);
+ let result = update(&args.site_name, None, &config).await;
deploy_exit(result);
}
AlkaneCommand::Init(args) => {
- let result = initialize(&args.site_name, None, &config);
+ let result = initialize(&args.site_name, None, &config).await;
deploy_exit(result);
}
AlkaneCommand::Deploy(args) => {
- let result = deploy(&args.site_name, None, &config);
+ let result = deploy(&args.site_name, None, &config).await;
deploy_exit(result);
}
diff --git a/src/runner/mod.rs b/src/runner/mod.rs
--- a/src/runner/mod.rs
+++ b/src/runner/mod.rs
@@ -8,10 +8,10 @@
use std::ffi::OsStr;
use std::fmt::{Debug, Display};
-use std::process::Command;
use log::{error, info, warn};
use serde::Serialize;
+use tokio::process::Command;
// -------------------------------------------------------------
// Modules
@@ -59,7 +59,7 @@
// Run an executable, returns the recipe status
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-pub fn run<E, I, S>(command: S, args: I, environment: E) -> RecipeStatus
+pub async fn run<E, I, S>(command: S, args: I, environment: E) -> RecipeStatus
where
E: IntoIterator<Item = (S, S)>,
I: IntoIterator<Item = S> + Debug,
@@ -67,7 +67,11 @@
{
info!("Running command {} with args {:?}", command, args);
- let result = Command::new(command).args(args).envs(environment).output();
+ let result = Command::new(command)
+ .args(args)
+ .envs(environment)
+ .output()
+ .await;
match result {
Ok(process_output) => {
diff --git a/src/runner/store.rs b/src/runner/store.rs
--- a/src/runner/store.rs
+++ b/src/runner/store.rs
@@ -40,11 +40,11 @@
.to_string()
}
- pub fn run_recipe(&self, site: &Site, action: &str) -> RecipeStatus {
+ pub async fn run_recipe(&self, site: &Site, action: &str) -> RecipeStatus {
let command = self.get_recipe_path(&site.name, action);
let environment = self.get_environment(&site);
- run(command, Vec::new(), environment)
+ run(command, Vec::new(), environment).await
}
fn get_environment(&self, site: &Site) -> HashMap<String, String> {
diff --git a/src/server/requests.rs b/src/server/requests.rs
--- a/src/server/requests.rs
+++ b/src/server/requests.rs
@@ -47,6 +47,7 @@
debug!("Context: {:?}", &context);
actions::initialize(&site_name, context, &config)
+ .await
.into_json_response()
}
@@ -61,6 +62,7 @@
debug!("Context: {:?}", &context);
actions::update(&site_name, context, &config)
+ .await
.into_json_response()
}
@@ -75,6 +77,7 @@
debug!("Context: {:?}", &context);
actions::deploy(&site_name, context, &config)
+ .await
.into_json_response()
}

File Metadata

Mime Type
text/plain
Expires
Mon, Aug 10, 20:38 (20 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3983217
Default Alt Text
D4149.diff (4 KB)

Event Timeline