log the status message to stdout

(cherry picked from commit ac49589ac40eed229ba8eee8d1192a3227c80e23)
This commit is contained in:
licunlong 2023-08-31 19:08:37 +08:00 committed by openeuler-sync-bot
parent 699a4a07e6
commit cde20a2379
2 changed files with 56 additions and 1 deletions

View File

@ -0,0 +1,51 @@
From 02168f76edce7622dbd72742a45bffa1f9eed5f2 Mon Sep 17 00:00:00 2001
From: licunlong <licunlong1@huawei.com>
Date: Thu, 31 Aug 2023 16:47:13 +0800
Subject: [PATCH] fix: log the status message to stdout
---
core/sctl/src/main.rs | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/core/sctl/src/main.rs b/core/sctl/src/main.rs
index fb949f39..2a721d89 100755
--- a/core/sctl/src/main.rs
+++ b/core/sctl/src/main.rs
@@ -14,9 +14,12 @@
#![allow(deprecated)]
use clap::Parser;
-use cmdproto::proto::{
- abi::{sys_comm, unit_comm, CommandRequest},
- mngr_comm, unit_file, ProstClientStream,
+use cmdproto::{
+ error::ERROR_CODE_MASK_PRINT_STDOUT,
+ proto::{
+ abi::{sys_comm, unit_comm, CommandRequest},
+ mngr_comm, unit_file, ProstClientStream,
+ },
};
use constants::SCTL_SOCKET;
use std::process::exit;
@@ -251,13 +254,12 @@ fn main() {
exit(0);
}
- if data.error_code == 0 {
- /* Don't care if we fail to write the error out. */
+ if data.error_code == 0 || (data.error_code & ERROR_CODE_MASK_PRINT_STDOUT != 0) {
+ /* Don't care if we fail to write the message out. */
let _ = writeln!(std::io::stdout(), "{}", data.message);
- exit(0);
+ } else {
+ eprintln!("{}", data.message);
}
- eprintln!("{}", data.message);
-
- exit(data.error_code as i32);
+ exit((data.error_code & !ERROR_CODE_MASK_PRINT_STDOUT) as i32);
}
--
2.30.2

View File

@ -11,7 +11,7 @@
Name: sysmaster
Version: 0.2.5
Release: 2
Release: 3
Summary: redesign and reimplement process1.
License: Mulan PSL v2
@ -19,6 +19,7 @@ URL: https://gitee.com/openeuler/sysmaster
Source0: %{name}-%{version}.tar.gz
Patch6001: backport-fix-delete-and-re-add-the-restart-timer-to-make-time.patch
Patch6002: backport-fix-log-the-status-message-to-stdout.patch
ExclusiveArch: x86_64 aarch64
@ -71,6 +72,9 @@ install -Dm0640 -t %{buildroot}/etc/sysmaster %{conf_install_source}/system.conf
/etc/sysmaster/system.conf
%changelog
* Thu Aug 31 2023 licunlong<licunlong1@huawei.com> - 0.2.5-3
- log the status message to stdout
* Fri Aug 25 2023 licunlong<licunlong1@huawei.com> - 0.2.5-2
- sync patches from upstream