![]() |
AlarmNotifications
PANDA Slow Control Alarm Daemon
|
Alarm Notification daemon. More...
#include <daemon.h>
Public Member Functions | |
~Daemon () | |
Destructor. More... | |
Daemon (const Daemon &other)=delete | |
Copy constructor (deleted) More... | |
Daemon (Daemon &&other)=delete | |
Move constructor (C++11, deleted) More... | |
Daemon & | operator= (const Daemon &other)=delete |
Copy assignment (deleted) More... | |
Daemon & | operator= (Daemon &&other)=delete |
Move assignment (C+11, deleted) More... | |
void | run () |
Main daemon loop. More... | |
Static Public Member Functions | |
static Daemon & | instance () |
Get singleton instance. More... | |
Private Member Functions | |
Daemon () | |
Constructor. More... | |
Static Private Member Functions | |
static void | signalReceiver (int signum) |
POSIX signal handler. More... | |
Private Attributes | |
bool | _run |
Global daemon run flag. More... | |
__sighandler_t | hsigint |
Original SIGINT handler. More... | |
__sighandler_t | hsighup |
Original SIGHUP handler. More... | |
__sighandler_t | hsigquit |
Original SIGQUIT handler. More... | |
__sighandler_t | hsigusr1 |
Original SIGUSR1 handler. More... | |
__sighandler_t | hsigusr2 |
Original SIGUSR2 handler. More... | |
__sighandler_t | hsigterm |
Original SIGTERM handler. More... | |
AlarmServerConnector | _asc |
Connection to the CSS Alarm Server. More... | |
Static Private Attributes | |
static const unsigned short int | DaemonSleepTimeout = 3 |
Timeout for daemon status message. More... | |
Alarm Notification daemon.
This class implements a daemon that can be run in the background. It instanciates the AlarmServerConnector class that will send laboratory, desktop and e-mail Notifications according to the AlarmConfiguration.
The daemon is implemented as a singleton. It will take control of several POSIX signals such as SIGINT that is caused by pressing Ctrl+C. This way, the program will not be aborted, but the daemon's run() method will stop which will cause the entry point method (int main) to reach its end. The C++ runtime will then destroy all the global objects including this singleton, so the connection to the Java Message Service established by the CMSClient will be closed properly.
|
private |
Constructor.
Sets the _run flag to true and installs signalReceiver as the new POSIX signal handler for several signals while backing up the original signal handlers.
Definition at line 65 of file daemon.cpp.
Daemon::~Daemon | ( | ) |
|
delete |
|
delete |
Move constructor (C++11, deleted)
This class cannot be moved.
other | Another instance of Daemon |
|
static |
Get singleton instance.
This static method returns a reference (not a pointer!) to the singleton instance of the daemon class. On the first call to instance(), this singleton instance will be created and the constructor will be called. If an exception occurs in the constructor, instance() will call ExceptionHandler() to print an error message and then terminate the application.
Definition at line 44 of file daemon.cpp.
Copy assignment (deleted)
This class cannot be copied.
other | Another instance of Daemon |
Move assignment (C+11, deleted)
This class cannot be moved.
other | Another instance of Daemon |
void Daemon::run | ( | ) |
Main daemon loop.
This method will run a loop that prints a status message every DaemonSleepTimeout seconds. When _run is set to false, the loop will be terminated and the daemon process will exit.
Definition at line 82 of file daemon.cpp.
|
staticprivate |
POSIX signal handler.
Method to be registered with the operating system to be invoked whenever a POSIX signal such as SIGINT, SIGHUP, SIGQUIT, SIGUSR1, SIGUSR2 or SIGTERM is received.
Upon reception of such a signal, it will set the _run flag to tell the daemon process to stop and then restore the original handlers for the aforementioned signals. This way, the application can be killed by another Ctrl+C if for some reason the C++ runtime fails to exit properly.
signum | Signal number as defined in the POSIX standard |
Definition at line 107 of file daemon.cpp.
|
private |
Connection to the CSS Alarm Server.
This is the central instance of the AlarmServerConnector that administrates the connection to BEAST and sends out all the Notifications as configured.
|
private |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |