NAME
Kernel::System::Daemon::BaseDaemon – daemon base class
DESCRIPTION
Base class for daemon modules.
ATTRIBUTES
has NodeID
Contains the current node identifier for the running daemon.
has DaemonName
The Name of the Daemon Task shown in the Debug Messages
has JSON
Whether the Console Messages should be formatted in JSON
has PrintRaw
Whether the Console Messages should not be formatted at all
has AddTime
Whether the Console Messages should contain a Timestamp string
has Debug
Enable Debug Messages
has Test
Controls the test mode.
has ForeGround
Enable Foreground Mode
has SleepPost
Controls the amount of time to sleep after a loop.
has Discard
Defines the life time of the object as iteration count.
Object has to be re-created every hour
has DiscardCount
A iteration counter to determine the time lived of the object. It will be deceased with each iteration.
The counter is initialized from the attributes Discard
.
Is very important for the PreRun()
method.
METHODS
around 'BUILDARGS()'
Create a Daemon Module object.
Read additional configurations from the System Configuration Settings
PreRun()
Perform additional validations/preparations and wait times before Run().
The default behaviour checks the database connection every minute.
This method can be extended in derived Daemon Modules with around
or after
.
If this method returns true, execution will be continued. If it returns false, the main daemon aborts at this point, and Run() will not be called and the complete daemon module dies waiting to be recreated again in the next loop.
Run()
Runs the daemon.
Override this method in your daemons.
If this method returns true, execution will be continued. If it returns false, the main daemon aborts at this point, and PostRun() will not be called and the complete daemon module dies waiting to be recreated again in the next loop.
PostRun()
Perform additional clean-ups and wait times after Run().
Override this method in your daemons.
If this method returns true, execution will be continued. If it returns false, the main daemon aborts at this point, and PreRun() will not be called again and the complete daemon module dies waiting to be recreated again in the next loop.
Summary()
Provides a summary of what is the daemon doing in the current time, the summary is in form of tabular data and it must contain a header, the definition of the columns, the data, and a message if there was no data.
my @Summary = $DaemonObject->Summary();
returns
@Summary = (
{
Header => 'Header Message',
Column => [
{
Name => 'somename',
DisplayName => 'some name',
Size => 40,
},
# ...
],
Data => [
{
somename => $ScalarValue,
# ...
},
# ...
],
NoDataMessage => "Show this message if there is no data.",
},
);
Override this method in your daemons.
Print()
This method will print the given text to STDOUT
.
PrintError()
This method will print the given text to STDERR
.
You can add color tags (<green>...</green>, <yellow>...</yellow>, <red>...</red>
) to your text, and they will be replaced with the corresponding terminal escape sequences if the terminal supports it.