Sign in Join
FPDoc Onlineexperiment

DaemonApp unit

Daemon (service) application class.

The daemonapp unit implements a TApplication class which encapsulates a daemon or service application. It handles installation where this is necessary, and does instantiation of the various daemons where necessary.

The unit consists of 3 separate classes which cooperate tightly:

TDaemon
This is a class that implements the daemon's functionality. One or more descendents of this class can be implemented and instantiated in a single daemon application. For more information, see TDaemon.
TDaemonApplication
This is the actual daemon application class. A global instance of this class is instantiated. It handles the command-line arguments, and instantiates the various daemons. For more information, see TDaemonApplication.
TDaemonDef
This class defines the daemon in the operation system. The TDaemonApplication class has a collection of TDaemonDef instances, which it uses to start the various daemons. For more information, see TDaemonDef.

As can be seen, a single application can implement one ore more daemons (services). Each daemon will be run in a separate thread which is controlled by the application class.

The classes take care of logging through the TEventLog class.

Many options are needed only to make the application behave as a windows service application on windows. These options are ignored in UNIX-like environment. The documentation will mention this.

Classes and records

EDaemonclassException used in all daemon application code.
TCustomDaemonclassBase daemon application class.
TCustomDaemonApplicationclassCustom daemon application class.
TCustomDaemonMapperclassDaemon mapper.
TDaemonclassDaemon class for visual development.
TDaemonApplicationclassDefault descendent of CustomDaemonApplication.
TDaemonControllerclassInternal daemon controller class.
TDaemonDefclassDaemon definition.
TDaemonDefsclassCollection of daemon definitions.
TDaemonMapperclassDaemon mapper for designing in IDE.
TDaemonThreadclassThread to run daemons in.
TDependenciesclassDependencies collection for a daemon.
TDependencyclassContainer to define dependencies on other services.
TWinBindingsclassWindows Daemon bindings (windows only).

Procedures and functions

ApplicationfunctionApplication instance.
DaemonErrorprocedureRaise an EDaemon exception.
RegisterDaemonApplicationClassprocedureRegister alternative TCustomDaemonApplication class.
RegisterDaemonClassprocedureRegister daemon.
RegisterDaemonMapperprocedureRegister a daemon mapper class.

Types

TCurrentStatusenumerationCurrent daemon status.
TCustomControlCodeEventprocedure typePrototype for event to handle a custom control code.
TCustomControlCodeEvEventprocedure type
TCustomDaemonApplicationClasstypeClass pointer for TCustomDaemonApplication.
TCustomDaemonClasstypeClass type for TCustomDaemon.
TCustomDaemonMapperClasstypeClass of TCustomDaemonMapper.
TDaemonClasstypeClass type of TDaemon.
TDaemonEventprocedure typeDaemon event handler prototype.
TDaemonOKEventprocedure typeDaemon acknowledgement event handler.
TDaemonOptionenumerationDaemon options.
TDaemonOptionssetSet of options.
TDaemonRunModeenumerationDaemon application run mode.
TErrorSeverityenumerationSeverity of a startup error (Windows only).
TGuiLoopEventprocedure typeGUI loop event mechanism.
TServiceTypeenumerationType of service (Windows only).
TStartTypeenumerationWhen should the daemon be started (windows only).
TWinControlCodeenumeration
TWinControlCodesset

Resource strings

SControlFailedresource stringThe control code was not handled correctly.
SCustomCoderesource stringA custom code was received.
SDaemonStatusresource stringDaemon status report log message.
SErrApplicationAlreadyCreatedresource stringA second application instance is created.
SErrDaemonStartFailedresource stringThe application failed to start the daemon.
SErrDuplicateNameresource stringDuplicate service name.
SErrNoDaemonDefForStatusresource stringInternal error: no daemon definition to report status for.
SErrNoDaemonForStatusresource stringInternal error: no daemon to report status for.
SErrNoServiceMapperresource stringNo service mapper was found.
SErrNothingToDoresource stringNo operation can be performed.
SErrOnlyOneMapperAllowedresource stringAn attempt was made to install a second service mapper.
SErrServiceManagerStartFailedresource stringUnable to start or contact the service manager.
SErrUnknownDaemonClassresource stringUnknown daemon class requested.
SErrWindowClassresource stringCould not register window class.
SHelpCommandresource stringOptions message displayed when writing help to the console.
SHelpInstallresource stringInstall option message displayed when writing help to the console.
SHelpRunresource stringRun option message displayed when writing help to the console.
SHelpUnInstallresource stringUninstall option message displayed when writing help to the console.
SHelpUsageresource stringUsage message displayed when writing help to the console.

Variables

AppClassvariableDefault class used when creating the application instance.
CurrentStatusNamesvariableNames for various service statuses.
DefaultDaemonOptionsvariableDefault daemon options.
SStatusvariableStatus message.

Uses

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.