From 8af17b0a8f7db0aa8ad0219f244ada83a4427f96 Mon Sep 17 00:00:00 2001 From: nandan Date: Wed, 7 Dec 2022 13:55:41 +0530 Subject: [PATCH 1/5] FOGL-7103: Modifed to restart notification service in case of SIGTERM signal Signed-off-by: nandan --- C/services/common/notification_service.cpp | 12 ++++++++++-- C/services/notification/notification.cpp | 9 ++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/C/services/common/notification_service.cpp b/C/services/common/notification_service.cpp index 121aac6..61faf84 100644 --- a/C/services/common/notification_service.cpp +++ b/C/services/common/notification_service.cpp @@ -290,8 +290,16 @@ bool NotificationService::start(string& coreAddress, // - Notification API listener is already down. // - all subscriptions already unregistered - // Unregister from storage service - m_mgtClient->unregisterService(); + if (m_restartRequest) + { + // Request the Fledge core to restart the service + m_mgtClient->restartService(); + } + else + { + // Unregister from Fledge + m_mgtClient->unregisterService(); + } // Stop management API m_managementApi->stop(); diff --git a/C/services/notification/notification.cpp b/C/services/notification/notification.cpp index b91c885..8b143a2 100644 --- a/C/services/notification/notification.cpp +++ b/C/services/notification/notification.cpp @@ -47,7 +47,14 @@ static void signalHandler(int signal) if (service) { // Call stop() method in notification service class - service->stop(); + if (signal == SIGTERM) + { + service->restart(); + } + else + { + service->stop(); + } } } From 26d6c321e470733e65ace84a6e884a233303f99a Mon Sep 17 00:00:00 2001 From: nandan Date: Mon, 12 Dec 2022 13:40:29 +0530 Subject: [PATCH 2/5] FOGL-7103: Modified to stop unregistering service from core in case of SIGTERM signal Signed-off-by: nandan --- C/services/common/include/notification_service.h | 3 ++- C/services/common/notification_service.cpp | 11 ++++++++--- C/services/notification/notification.cpp | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/C/services/common/include/notification_service.h b/C/services/common/include/notification_service.h index 25e2638..dcd4849 100644 --- a/C/services/common/include/notification_service.h +++ b/C/services/common/include/notification_service.h @@ -35,7 +35,7 @@ class NotificationService : public ServiceAuthHandler const std::string& getName() { return m_name; }; bool start(std::string& coreAddress, unsigned short corePort); - void stop(); + void stop(bool remvoeFromCore=true); void shutdown(); void restart(); bool isRunning() { return !m_shutdown; }; @@ -74,5 +74,6 @@ class NotificationService : public ServiceAuthHandler const std::string m_token; bool m_dryRun; bool m_restartRequest; + bool m_removeFromCore; }; #endif diff --git a/C/services/common/notification_service.cpp b/C/services/common/notification_service.cpp index 61faf84..81fad10 100644 --- a/C/services/common/notification_service.cpp +++ b/C/services/common/notification_service.cpp @@ -40,7 +40,8 @@ NotificationService::NotificationService(const string& myName, m_shutdown(false), m_token(token), m_dryRun(false), - m_restartRequest(false) + m_restartRequest(false), + m_removeFromCore(true) { // Set name m_name = myName; @@ -295,7 +296,7 @@ bool NotificationService::start(string& coreAddress, // Request the Fledge core to restart the service m_mgtClient->restartService(); } - else + else if (m_removeFromCore) { // Unregister from Fledge m_mgtClient->unregisterService(); @@ -321,10 +322,14 @@ bool NotificationService::start(string& coreAddress, * Unregister notification subscriptions and * stop NotificationAPi listener */ -void NotificationService::stop() +void NotificationService::stop(bool remvoeFromCore) { m_logger->info("Stopping Notification service '" + m_name + "' ..."); + if (remvoeFromCore == false) + { + m_removeFromCore = false; + } // Unregister notifications to storage service NotificationSubscription* subscriptions = NotificationSubscription::getInstance(); if (subscriptions) diff --git a/C/services/notification/notification.cpp b/C/services/notification/notification.cpp index 8b143a2..97dfae5 100644 --- a/C/services/notification/notification.cpp +++ b/C/services/notification/notification.cpp @@ -49,7 +49,7 @@ static void signalHandler(int signal) // Call stop() method in notification service class if (signal == SIGTERM) { - service->restart(); + service->stop(false); } else { From 3ee004878c728b680009a2299ab225dc0f6e0b52 Mon Sep 17 00:00:00 2001 From: Mohit04tomar <43023917+Mohit04tomar@users.noreply.github.com> Date: Mon, 12 Dec 2022 14:12:14 +0530 Subject: [PATCH 3/5] FOGL-7177 Compilation of fledge-service-notification failed in Centos Stream 9 (#60) * Commented unusable code for Centos Stream 9 Signed-off-by: Mohit Tomar * Replace Check for Centos 7 to Centos Stream 9 Signed-off-by: Mohit Tomar * Refactored code Signed-off-by: Mohit Tomar * Added code for using scl_source in Centos 7 only Signed-off-by: Mohit Tomar * Fixed typos and Refactored code Signed-off-by: Mohit Tomar * Removed OS NAME check from build_rhel.sh Signed-off-by: Mohit Tomar Signed-off-by: Mohit Tomar --- build.sh | 2 +- build_rhel.sh | 7 ++++++- requirements.sh | 29 ++++++++++++++++------------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/build.sh b/build.sh index f586d6d..24856ff 100755 --- a/build.sh +++ b/build.sh @@ -8,7 +8,7 @@ os_name=`(grep -o '^NAME=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g')` os_version=`(grep -o '^VERSION_ID=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g')` -if [[ ( $os_name == *"Red Hat"* || $os_name == *"CentOS"* ) && $os_version == *"7"* ]]; then +if [[ $os_name == *"Red Hat"* || $os_name == *"CentOS"* ]]; then if [ -f build_rhel.sh ]; then echo "Custom build for platform is ${os_name}, Version: ${os_version}" ./build_rhel.sh $@ diff --git a/build_rhel.sh b/build_rhel.sh index fe77666..1d80e1e 100755 --- a/build_rhel.sh +++ b/build_rhel.sh @@ -6,7 +6,12 @@ # The new gcc 7 is now available using the command 'source scl_source enable devtoolset-7' # the previous gcc will be enabled again after this script exits -source scl_source enable devtoolset-7 +os_version=$(grep -o '^VERSION_ID=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g') +# Use scl_source only if OS is RedHat/CentOS 7 +if [[ $os_version == *"7"* ]] +then + source scl_source enable devtoolset-7 +fi mkdir build cd build/ diff --git a/requirements.sh b/requirements.sh index 7790aae..6d1768d 100755 --- a/requirements.sh +++ b/requirements.sh @@ -23,18 +23,28 @@ set -e -fledge_location=`pwd` -os_name=`(grep -o '^NAME=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g')` -os_version=`(grep -o '^VERSION_ID=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g')` +fledge_location=$(pwd) +os_name=$(grep -o '^NAME=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g') +os_version=$(grep -o '^VERSION_ID=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g') echo "Platform is ${os_name}, Version: ${os_version}" -if [[ ( $os_name == *"Red Hat"* || $os_name == *"CentOS"* ) && $os_version == *"7"* ]]; then +if [[ ( $os_name == *"Red Hat"* || $os_name == *"CentOS"* ) ]]; then if [[ $os_name == *"Red Hat"* ]]; then sudo yum-config-manager --enable 'Red Hat Enterprise Linux Server 7 RHSCL (RPMs)' sudo yum install -y @development else sudo yum groupinstall "Development tools" -y - sudo yum install -y centos-release-scl + # Install centos-release-scl only if OS is CentOS 7 + if [[ $os_version == *"7"* ]]; + then + sudo yum install -y centos-release-scl + # A gcc version newer than 4.9.0 is needed to properly use + # the installation of these packages will not overwrite the previous compiler + # the new one will be available using the command 'source scl_source enable devtoolset-7' + # the previous gcc will be enabled again after a log-off/log-in. + sudo yum-config-manager --enable rhel-server-rhscl-7-rpms + sudo yum install -y devtoolset-7 + fi fi sudo yum install -y boost-devel sudo yum install -y glib2-devel @@ -45,15 +55,8 @@ if [[ ( $os_name == *"Red Hat"* || $os_name == *"CentOS"* ) && $os_version == * sudo yum install -y git sudo yum install -y cmake sudo yum install -y libuuid-devel - - # A gcc version newer than 4.9.0 is needed to properly use - # the installation of these packages will not overwrite the previous compiler - # the new one will be available using the command 'source scl_source enable devtoolset-7' - # the previous gcc will be enabled again after a log-off/log-in. - # sudo yum install -y yum-utils - sudo yum-config-manager --enable rhel-server-rhscl-7-rpms - sudo yum install -y devtoolset-7 + elif apt --version 2>/dev/null; then sudo apt install -y avahi-daemon curl sudo apt install -y cmake g++ make build-essential autoconf automake uuid-dev From 818e1ac9c94380124a2a05d45f87d46944824af5 Mon Sep 17 00:00:00 2001 From: nandan Date: Mon, 12 Dec 2022 21:27:52 +0530 Subject: [PATCH 4/5] FOGL-7103: Fixed the typo Signed-off-by: nandan --- C/services/common/include/notification_service.h | 2 +- C/services/common/notification_service.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/C/services/common/include/notification_service.h b/C/services/common/include/notification_service.h index dcd4849..ebe4665 100644 --- a/C/services/common/include/notification_service.h +++ b/C/services/common/include/notification_service.h @@ -35,7 +35,7 @@ class NotificationService : public ServiceAuthHandler const std::string& getName() { return m_name; }; bool start(std::string& coreAddress, unsigned short corePort); - void stop(bool remvoeFromCore=true); + void stop(bool removeFromCore=true); void shutdown(); void restart(); bool isRunning() { return !m_shutdown; }; diff --git a/C/services/common/notification_service.cpp b/C/services/common/notification_service.cpp index 81fad10..425381b 100644 --- a/C/services/common/notification_service.cpp +++ b/C/services/common/notification_service.cpp @@ -322,11 +322,11 @@ bool NotificationService::start(string& coreAddress, * Unregister notification subscriptions and * stop NotificationAPi listener */ -void NotificationService::stop(bool remvoeFromCore) +void NotificationService::stop(bool removeFromCore) { m_logger->info("Stopping Notification service '" + m_name + "' ..."); - if (remvoeFromCore == false) + if (removeFromCore == false) { m_removeFromCore = false; } From afd1616193f4d7338cf99af510a2fd74abe30857 Mon Sep 17 00:00:00 2001 From: dianomicbot Date: Mon, 26 Dec 2022 16:32:17 +0000 Subject: [PATCH 5/5] VERSION changed Signed-off-by: dianomicbot --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 3edc50d..3844610 100755 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -fledge_version>=2.0 -notification_version=2.0.1 +fledge_version>=2.1 +notification_version=2.1.0