Commit 122b46e9 authored by Xiaowu Zhang's avatar Xiaowu Zhang

use sub process

parent b351ff81
......@@ -15,6 +15,5 @@ install() {
inst "$moddir"/fluent-bit "/sbin/fluent-bit"
inst "$moddir"/flb.conf "/etc/flb.conf"
inst "$moddir"/out_gstdout.so "/etc/out_gstdout.so"
inst "$moddir"/metadata_collect.log "/var/log/metadata_collect.log"
inst_hook pre-pivot 10 "$moddir"/collect.sh
}
......@@ -13,20 +13,10 @@ ERP5_PASS="$(ERP5_PASS)"
REFERENCE="COMP-MAC-$$(echo "$$DEFAULT_IF_MAC" | sed s/:/-/g).Metadata.Snapshot"
/sbin/fluent-bit -e /etc/out_gstdout.so -c /etc/flb.conf &
/sbin/metadata-collect-agent "$$NEWROOT" "$$ERP5_USER" "$$ERP5_PASS" "$$REFERENCE" "$$ERP5_BASE_URL"
echo "[2020: 2122222]" >> /var/log/metadata_collect.log
echo "[2020: 1234232]" >> /var/log/metadata_collect.log
fluent_bit_is_running="$$(ps -ef | grep "fluent-bit" | grep -v "grep")"
echo $${fluent_bit_is_running}
while [ -z "$${fluent_bit_is_running}" ];do
sleep 10
fluent_bit_is_running="$$(ps -ef | grep "fluent-bit" | grep -v "grep")"
echo $${fluent_bit_is_running}
done
endef
......
......@@ -19,6 +19,11 @@ use std::{
time::Duration,
};
use std::process::Command;
use std::io::prelude::*;
use std::fs::OpenOptions;
#[derive(Debug, Serialize)]
struct FileStat {
st_dev: u64,
......@@ -347,6 +352,7 @@ fn main() -> Result<()> {
let packed = serde_json::to_vec(&snapshot)?;
let packed_size = packed.len() as u64;
let mut file = OpenOptions::new().write(true).append(true).create(true).open("/var/log/metadata_collect.log").unwrap();
upload_to_erp5(
Cursor::new(packed),
packed_size,
......@@ -356,5 +362,12 @@ fn main() -> Result<()> {
m.value_of("erp5-file-reference").unwrap(),
)?;
let mut child = Command::new("/sbin/fluent-bit").args(&["-e","/etc/out_gstdout.so","-c","/etc/flb.conf"]).spawn().unwrap();
thread::sleep(Duration::from_secs(60));
writeln!(file, "[200202: 2002020]");
writeln!(file, "[2020222:20390294]");
let _result = child.wait().unwrap();
Ok(())
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment