libmoost
moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy > Class Template Reference

Configurable template implementing common functionality to run a service. More...

#include <skeleton.hpp>

Inheritance diagram for moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >:
Collaboration diagram for moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >:

List of all members.

Classes

class  child_init_func

Public Member Functions

 skeleton ()
virtual ~skeleton ()
virtual int main (int argc, char **argv, bool noargs)
 Main entry point for skeleton.

Protected Types

typedef ServiceT ServiceType

Protected Member Functions

virtual void add_options (boost::program_options::options_description &)
 Add custom options for your service.
virtual void add_options (boost::program_options::options_description &, option_validator &)
 Add custom options for your service, with validator support.
virtual void validate_options () const
 Add options validation code.
virtual std::string name () const =0
 Return the service name.
virtual std::string version () const =0
 Return the service version.
virtual std::string description () const =0
 Return short description of the service.
virtual std::string copyright () const =0
 Return copyright string.
virtual boost::shared_ptr
< ServiceType
create_service_instance ()=0
 Create the service instance.
virtual std::string help_header () const
 Return header for help message.
bool logging_enabled () const
 Check whether or not the logging framework is already set up.
const
boost::program_options::variables_map & 
options () const
 Read-only access to command line options variable map.
bool running_as_daemon () const
 Check whether the service is about to be started in daemon mode.
void process_cmdline_options (boost::program_options::options_description &cmdline_options, option_validator &opt_validator, int argc, char **argv)
 Set up and process command line options.
int safe_main (int argc, char **argv, bool noargs)
 Safe main() implementation.
virtual void run ()
 Run the service.
void run_service ()
 Run the service.

Private Types

typedef
moost::process::service
< ServiceT,
ConsoleLoggerPolicy > 
ProcessServiceType

Private Attributes

bool m_logging_enabled
bool m_options_valid
std::string m_pidfile
unsigned short m_shell_port
boost::program_options::variables_map m_opt_varmap
ProcessOwnershipPolicy m_ownership
LoggingPolicy m_logging
std::string m_program_name

Detailed Description

template<class ServiceT, class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
class moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >

Configurable template implementing common functionality to run a service.

Definition at line 339 of file skeleton.hpp.


Member Typedef Documentation

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
typedef moost::process::service<ServiceT, ConsoleLoggerPolicy> moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::ProcessServiceType [private]

Definition at line 351 of file skeleton.hpp.

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
typedef ServiceT moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::ServiceType [protected]

Definition at line 381 of file skeleton.hpp.


Constructor & Destructor Documentation

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::skeleton ( ) [inline]

Definition at line 618 of file skeleton.hpp.

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
virtual moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::~skeleton ( ) [inline, virtual]

Definition at line 625 of file skeleton.hpp.


Member Function Documentation

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
virtual void moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::add_options ( boost::program_options::options_description &  ) [inline, protected, virtual]

Add custom options for your service.

Override this if you want to define any extra command line options for your service.

Definition at line 388 of file skeleton.hpp.

Here is the caller graph for this function:

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
virtual void moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::add_options ( boost::program_options::options_description &  ,
option_validator  
) [inline, protected, virtual]

Add custom options for your service, with validator support.

Override this if you want to define any extra command line options for your service.

Definition at line 397 of file skeleton.hpp.

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
virtual std::string moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::copyright ( ) const [protected, pure virtual]

Return copyright string.

Here is the caller graph for this function:

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
virtual boost::shared_ptr<ServiceType> moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::create_service_instance ( ) [protected, pure virtual]

Create the service instance.

This method creates the instance of the service class after all checks have been carried out, logging is set up and the process is running as a non-privileged user.

Here is the caller graph for this function:

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
virtual std::string moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::description ( ) const [protected, pure virtual]

Return short description of the service.

Here is the caller graph for this function:

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
virtual std::string moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::help_header ( ) const [inline, protected, virtual]

Return header for help message.

Override this if you really need full control over the service header that is written to the console along with the command line options description.

Definition at line 445 of file skeleton.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
bool moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::logging_enabled ( ) const [inline, protected]

Check whether or not the logging framework is already set up.

This is primarily useful for implementing custom catch() blocks in main().

Definition at line 459 of file skeleton.hpp.

Here is the caller graph for this function:

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
virtual int moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::main ( int  argc,
char **  argv,
bool  noargs 
) [inline, virtual]

Main entry point for skeleton.

Override this if you want to catch exceptions other than std:::exception or you want to supply custom exception handling code. Make sure you don't change the try { } block in your implementation and only call safe_main().

Definition at line 636 of file skeleton.hpp.

Here is the call graph for this function:

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
virtual std::string moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::name ( ) const [protected, pure virtual]

Return the service name.

Here is the caller graph for this function:

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
const boost::program_options::variables_map& moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::options ( ) const [inline, protected]

Read-only access to command line options variable map.

Call this method to validate/access command line options.

Definition at line 469 of file skeleton.hpp.

Here is the caller graph for this function:

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
void moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::process_cmdline_options ( boost::program_options::options_description &  cmdline_options,
option_validator opt_validator,
int  argc,
char **  argv 
) [inline, protected]

Set up and process command line options.

Definition at line 490 of file skeleton.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
virtual void moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::run ( ) [inline, protected, virtual]

Run the service.

Override this if you want to do anything else than just running the service depending on the commandline options. To actually run the service, call run_service() from within your override.

Definition at line 580 of file skeleton.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
void moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::run_service ( ) [inline, protected]

Run the service.

Creates, configures and runs a service instance. Make sure you call this from run() at some point when overriding it.

Definition at line 591 of file skeleton.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
bool moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::running_as_daemon ( ) const [inline, protected]

Check whether the service is about to be started in daemon mode.

Definition at line 482 of file skeleton.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
int moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::safe_main ( int  argc,
char **  argv,
bool  noargs 
) [inline, protected]

Safe main() implementation.

Definition at line 515 of file skeleton.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
virtual void moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::validate_options ( ) const [inline, protected, virtual]

Add options validation code.

Override this if you want to supply code to check command line options consistency. You can access the raw option map using options().

Definition at line 407 of file skeleton.hpp.

Here is the caller graph for this function:

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
virtual std::string moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::version ( ) const [protected, pure virtual]

Return the service version.

Here is the caller graph for this function:


Member Data Documentation

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
LoggingPolicy moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::m_logging [private]

Definition at line 348 of file skeleton.hpp.

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
bool moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::m_logging_enabled [private]

Definition at line 342 of file skeleton.hpp.

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
boost::program_options::variables_map moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::m_opt_varmap [private]

Definition at line 346 of file skeleton.hpp.

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
bool moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::m_options_valid [private]

Definition at line 343 of file skeleton.hpp.

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
ProcessOwnershipPolicy moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::m_ownership [private]

Definition at line 347 of file skeleton.hpp.

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
std::string moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::m_pidfile [private]

Definition at line 344 of file skeleton.hpp.

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
std::string moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::m_program_name [private]

Definition at line 349 of file skeleton.hpp.

template<class ServiceT , class ProcessOwnershipPolicy = UidGidProcessOwnershipPolicy, class LoggingPolicy = MoostLoggingPolicy, class ConsoleLoggerPolicy = typename LoggingPolicy::DefaultConsoleLoggerPolicy>
unsigned short moost::service::skeleton< ServiceT, ProcessOwnershipPolicy, LoggingPolicy, ConsoleLoggerPolicy >::m_shell_port [private]

Definition at line 345 of file skeleton.hpp.


The documentation for this class was generated from the following file: