Skip to content

Commit

Permalink
Merge pull request #62 from fledge-iot/2.1.0RC
Browse files Browse the repository at this point in the history
2.1.0RC
  • Loading branch information
dianomicbot authored Jan 4, 2023
2 parents 1ca10ad + afd1616 commit 7816c32
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 23 deletions.
3 changes: 2 additions & 1 deletion C/services/common/include/notification_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 removeFromCore=true);
void shutdown();
void restart();
bool isRunning() { return !m_shutdown; };
Expand Down Expand Up @@ -74,5 +74,6 @@ class NotificationService : public ServiceAuthHandler
const std::string m_token;
bool m_dryRun;
bool m_restartRequest;
bool m_removeFromCore;
};
#endif
21 changes: 17 additions & 4 deletions C/services/common/notification_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -290,8 +291,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 if (m_removeFromCore)
{
// Unregister from Fledge
m_mgtClient->unregisterService();
}

// Stop management API
m_managementApi->stop();
Expand All @@ -313,10 +322,14 @@ bool NotificationService::start(string& coreAddress,
* Unregister notification subscriptions and
* stop NotificationAPi listener
*/
void NotificationService::stop()
void NotificationService::stop(bool removeFromCore)
{
m_logger->info("Stopping Notification service '" + m_name + "' ...");

if (removeFromCore == false)
{
m_removeFromCore = false;
}
// Unregister notifications to storage service
NotificationSubscription* subscriptions = NotificationSubscription::getInstance();
if (subscriptions)
Expand Down
9 changes: 8 additions & 1 deletion C/services/notification/notification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ static void signalHandler(int signal)
if (service)
{
// Call stop() method in notification service class
service->stop();
if (signal == SIGTERM)
{
service->stop(false);
}
else
{
service->stop();
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
fledge_version>=2.0
notification_version=2.0.1
fledge_version>=2.1
notification_version=2.1.0
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@
Expand Down
7 changes: 6 additions & 1 deletion build_rhel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
29 changes: 16 additions & 13 deletions requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <regex>
# 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
Expand All @@ -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 <regex>
# 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
Expand Down

0 comments on commit 7816c32

Please sign in to comment.