From 497b3124f017ce4ae99b34261c4fd5dd2a358f5b Mon Sep 17 00:00:00 2001
From: zhuofeng <zhuofeng2@huawei.com>
Date: Sat, 14 Sep 2024 09:28:00 +0800
Subject: [PATCH] fix syssentry fails to be started when cpu_sentry is not
 installed

---
 src/python/syssentry/syssentry.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/python/syssentry/syssentry.py b/src/python/syssentry/syssentry.py
index f93956e..776971f 100644
--- a/src/python/syssentry/syssentry.py
+++ b/src/python/syssentry/syssentry.py
@@ -43,7 +43,6 @@ try:
     from .cpu_alarm import cpu_alarm_recv
 except ImportError:
     CPU_EXIST = False
-    logging.debug("Cannot find cpu sentry mod")
 
 
 INSPECTOR = None
@@ -563,20 +562,21 @@ def main():
     if not os.path.exists(SENTRY_RUN_DIR):
         os.mkdir(SENTRY_RUN_DIR)
         os.chmod(SENTRY_RUN_DIR, mode=SENTRY_RUN_DIR_PERM)
-    if not chk_and_set_pidfile():
-        logging.error("get pid file lock failed, exist")
-        sys.exit(17)
 
     logging.basicConfig(filename=SYSSENTRY_LOG_FILE, level=logging.INFO)
     os.chmod(SYSSENTRY_LOG_FILE, 0o600)
 
+    if not chk_and_set_pidfile():
+        logging.error("get pid file lock failed, exist")
+        sys.exit(17)
+
     try:
         signal.signal(signal.SIGINT, sig_handler)
         signal.signal(signal.SIGTERM, sig_handler)
         signal.signal(signal.SIGHUP, sig_handler)
         signal.signal(signal.SIGCHLD, sigchld_handler)
 
-        logging.debug("finish main parse_args")
+        logging.info("finish main parse_args")
 
         _ = SentryConfig.init_param()
         TasksMap.init_task_map()
@@ -587,3 +587,4 @@ def main():
         logging.error('%s', traceback.format_exc())
     finally:
         release_pidfile()
+
-- 
2.33.0

