Skip to content

Commit

Permalink
Fixes #23769: Restart the webapp after plugin installation (#5187)
Browse files Browse the repository at this point in the history
  • Loading branch information
amousset authored Nov 22, 2023
1 parent f5b6eca commit 0b251ab
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
4 changes: 3 additions & 1 deletion relay/sources/rudder-package/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub mod action {

use crate::archive::Rpkg;
use crate::database::Database;
use crate::webapp_xml::restart_webapp;
use crate::PACKAGES_DATABASE_PATH;
use std::path::Path;

Expand All @@ -78,7 +79,8 @@ pub mod action {
bail!("TODO");
};
let rpkg = Rpkg::from_path(&rpkg_path)?;
rpkg.install(force)
rpkg.install(force)?;
restart_webapp()
}

pub fn list() -> Result<()> {
Expand Down
23 changes: 21 additions & 2 deletions relay/sources/rudder-package/src/webapp_xml.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2023 Normation SAS

use std::{collections::HashMap, fs::File, io::BufReader};
use std::{collections::HashMap, fs::File, io::BufReader, process::Command};

use anyhow::Result;
use anyhow::{bail, Result};
use log::debug;
use xmltree::Element;

use crate::cmd::CmdOutput;

/// Synchronous restart of the web application
pub fn restart_webapp() -> Result<()> {
debug!("Restarting the Weba application to apply plugin changes");
let mut systemctl = Command::new("/usr/bin/systemctl");
systemctl
.arg("--no-ask-password")
.arg("restart")
.arg("rudder-jetty");
match CmdOutput::new(&mut systemctl) {
Ok(_) => Ok(()),
Err(e) => {
bail!("Could not restart the Rudder application:\n{}", e)
}
}
}

pub struct WebappXml {
pub path: String,
emitter_config: xmltree::EmitterConfig,
Expand Down

0 comments on commit 0b251ab

Please sign in to comment.