A singleton class comparable to Ice::Application but also provides the low-level, platform-specific initialization and shutdown procedures common to system services.
More...
#include <Ice/Ice.h>
|
bool | checkSystem () const |
| Determines whether the operating system supports running the program as a Win32 service or Unix daemon. More...
|
|
Ice::CommunicatorPtr | communicator () const |
| Obtains the communicator created by the service. More...
|
|
void | configureDaemon (bool changeDirectory, bool closeFiles, const std::string &pidFile) |
| Configures the program to run as a Unix daemon. More...
|
|
virtual void | handleInterrupt (int sig) |
| Invoked by the signal handler when it catches a signal. More...
|
|
virtual void | interrupt () |
| Notify the service about a signal interrupt. More...
|
|
int | main (const StringSeq &args, const InitializationData &initData=InitializationData(), int version=30710) |
| The primary entry point for services. More...
|
|
int | main (int argc, const char *const argv[], const InitializationData &initData=InitializationData(), int version=30710) |
| The primary entry point for services. More...
|
|
std::string | name () const |
| Obtains the program name. More...
|
|
int | run (int argc, const char *const argv[], const InitializationData &initData=InitializationData(), int version=30710) |
| Alternative entry point for services that use their own command-line options. More...
|
|
| Service () |
|
bool | service () const |
| Indicates whether the program is running as a Win32 service or Unix daemon. More...
|
|
virtual bool | shutdown () |
| Shutdown the service. More...
|
|
virtual | ~Service () |
|
|
typedef LoggerOutput< Service, Service *, &Service::error > | ServiceError |
| Logger utility class for an error. More...
|
|
typedef LoggerOutput< Service, Service *, &Service::print > | ServicePrint |
| Logger utility class for a literal message. More...
|
|
typedef LoggerOutput< Service, Service *, &Service::syserror > | ServiceSysError |
| Logger utility class for a system error. More...
|
|
typedef LoggerOutput< Service, Service *, &Service::trace > | ServiceTrace |
| Logger utility class for a trace message. More...
|
|
typedef LoggerOutput< Service, Service *, &Service::warning > | ServiceWarning |
| Logger utility class for a warning. More...
|
|
A singleton class comparable to Ice::Application but also provides the low-level, platform-specific initialization and shutdown procedures common to system services.
◆ ServiceError
Logger utility class for an error.
◆ ServicePrint
Logger utility class for a literal message.
◆ ServiceSysError
Logger utility class for a system error.
◆ ServiceTrace
Logger utility class for a trace message.
◆ ServiceWarning
Logger utility class for a warning.
◆ Service()
Ice::Service::Service |
( |
| ) |
|
◆ ~Service()
virtual Ice::Service::~Service |
( |
| ) |
|
|
virtual |
◆ checkSystem()
bool Ice::Service::checkSystem |
( |
| ) |
const |
Determines whether the operating system supports running the program as a Win32 service or Unix daemon.
- Returns
- True if the system supports services, false otherwise.
◆ communicator()
Ice::CommunicatorPtr Ice::Service::communicator |
( |
| ) |
const |
Obtains the communicator created by the service.
- Returns
- The service's communicator.
◆ configureDaemon()
void Ice::Service::configureDaemon |
( |
bool |
changeDirectory, |
|
|
bool |
closeFiles, |
|
|
const std::string & |
pidFile |
|
) |
| |
Configures the program to run as a Unix daemon.
The first argument indicates whether the daemon should change its working directory to the root directory. The second argument indicates whether extraneous file descriptors are closed. If the value of the last argument is not an empty string, the daemon writes its process ID to the given filename.
- Parameters
-
changeDirectory | True if the daemon should change its working directory to the root directory, false otherwise. |
closeFiles | True if the daemon should close unnecessary file descriptors (i.e., stdin, stdout, etc.), false otherwise. |
pidFile | If a non-empty string is provided, the daemon writes its process ID to the given file. |
◆ disableInterrupt()
void Ice::Service::disableInterrupt |
( |
| ) |
|
|
protected |
◆ enableInterrupt()
void Ice::Service::enableInterrupt |
( |
| ) |
|
|
protected |
Enables the signal handler to invoke interrupt() when a signal occurs.
◆ error()
virtual void Ice::Service::error |
( |
const std::string & |
msg | ) |
|
|
protectedvirtual |
Logs an error.
- Parameters
-
◆ handleInterrupt()
virtual void Ice::Service::handleInterrupt |
( |
int |
sig | ) |
|
|
virtual |
Invoked by the signal handler when it catches a signal.
- Parameters
-
sig | The signal that was caught. |
◆ initializeCommunicator()
virtual Ice::CommunicatorPtr Ice::Service::initializeCommunicator |
( |
int & |
argc, |
|
|
char * |
argv[], |
|
|
const InitializationData & |
initData, |
|
|
int |
version |
|
) |
| |
|
protectedvirtual |
Initializes a communicator.
- Parameters
-
argc | Specifies the number of arguments in argv. |
argv | The command-line arguments. |
initData | Configuration data for the new Communicator. |
version | Indicates the Ice version with which the application is compatible. If not specified, the version of the Ice installation is used. |
- Returns
- The new communicator instance.
◆ instance()
static Service* Ice::Service::instance |
( |
| ) |
|
|
static |
Obtains the Service singleton.
- Returns
- A pointer to this service.
◆ interrupt()
virtual void Ice::Service::interrupt |
( |
| ) |
|
|
virtual |
Notify the service about a signal interrupt.
The default implementation invokes shutdown().
◆ main() [1/2]
The primary entry point for services.
This function examines the given argument vector for reserved options and takes the appropriate action. The reserved options are shown below.
Win32:
–service NAME
Unix:
–daemon [–nochdir] [–noclose]
If –service or –daemon are specified, the program runs as a service, otherwise the program runs as a regular foreground process. Any service-specific (and Ice-specific) options are stripped from argv (just as for Ice::initialize()).
- Parameters
-
args | The command-line arguments. |
initData | Configuration data for the new Communicator. |
version | Indicates the Ice version with which the application is compatible. If not specified, the version of the Ice installation is used. |
- Returns
- The application's exit status: EXIT_FAILURE or EXIT_SUCCESS.
◆ main() [2/2]
The primary entry point for services.
This function examines the given argument vector for reserved options and takes the appropriate action. The reserved options are shown below.
Win32:
–service NAME
Unix:
–daemon [–nochdir] [–noclose]
If –service or –daemon are specified, the program runs as a service, otherwise the program runs as a regular foreground process. Any service-specific (and Ice-specific) options are stripped from argv (just as for Ice::initialize()).
- Parameters
-
argc | Specifies the number of arguments in argv. |
argv | The command-line arguments. |
initData | Configuration data for the new Communicator. |
version | Indicates the Ice version with which the application is compatible. If not specified, the version of the Ice installation is used. |
- Returns
- The application's exit status: EXIT_FAILURE or EXIT_SUCCESS.
◆ name()
std::string Ice::Service::name |
( |
| ) |
const |
Obtains the program name.
If the program is running as a Win32 service, the return value is the service name. Otherwise the return value is the executable name (i.e., argv[0]).
- Returns
- The service name.
◆ print()
virtual void Ice::Service::print |
( |
const std::string & |
msg | ) |
|
|
protectedvirtual |
Logs a literal message.
- Parameters
-
◆ run()
Alternative entry point for services that use their own command-line options.
Instead of invoking main(), the program processes its command-line options and invokes run(). To run as a Win32 service or Unix daemon, the program must first invoke configureService() or configureDaemon(), respectively.
- Parameters
-
argc | Specifies the number of arguments in argv. |
argv | The command-line arguments. |
initData | Configuration data for the new Communicator. |
version | Indicates the Ice version with which the application is compatible. If not specified, the version of the Ice installation is used. |
- Returns
- The application's exit status: EXIT_FAILURE or EXIT_SUCCESS.
◆ service()
bool Ice::Service::service |
( |
| ) |
const |
Indicates whether the program is running as a Win32 service or Unix daemon.
- Returns
- True if the program is running as a service, false otherwise.
◆ shutdown()
virtual bool Ice::Service::shutdown |
( |
| ) |
|
|
virtual |
Shutdown the service.
The default implementation invokes shutdown() on the communicator.
◆ start()
virtual bool Ice::Service::start |
( |
int |
argc, |
|
|
char * |
argv[], |
|
|
int & |
status |
|
) |
| |
|
protectedpure virtual |
Prepares a service for execution, including the creation and activation of object adapters and servants.
- Parameters
-
argc | Specifies the number of arguments in argv. |
argv | The command-line arguments. |
status | The exit status, which is returned by main |
- Returns
- True if startup was successful, false otherwise.
◆ stop()
virtual bool Ice::Service::stop |
( |
| ) |
|
|
protectedvirtual |
Cleans up resources after shutting down.
◆ syserror()
virtual void Ice::Service::syserror |
( |
const std::string & |
msg | ) |
|
|
protectedvirtual |
Logs a system error, which includes a description of the current system error code.
- Parameters
-
◆ trace()
virtual void Ice::Service::trace |
( |
const std::string & |
msg | ) |
|
|
protectedvirtual |
Logs trace information.
- Parameters
-
◆ waitForShutdown()
virtual void Ice::Service::waitForShutdown |
( |
| ) |
|
|
protectedvirtual |
Blocks until the service shuts down.
The default implementation invokes waitForShutdown() on the communicator.
◆ warning()
virtual void Ice::Service::warning |
( |
const std::string & |
msg | ) |
|
|
protectedvirtual |
Logs a warning.
- Parameters
-
The documentation for this class was generated from the following file: