libassa  3.5.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
ASSA::GenServer Class Reference

#include <GenServer.h>

Inheritance diagram for ASSA::GenServer:
ASSA::EventHandler ASSA::CmdLineOpts

List of all members.

Public Types

enum  LogFlag { KEEPLOG, RMLOG }
- Public Types inherited from ASSA::CmdLineOpts
typedef void(* OPTS_FUNC )(void)
typedef void(* OPTS_FUNC_ONE )(const string &)
typedef vector< OptionOptionSet

Public Member Functions

 GenServer ()
 Constructor.
virtual ~GenServer ()
 Destructor.
virtual void init (int *argc, char *argv[], const char *help_info)
 Provide an entry point into the service and perfom initialization of the service.
virtual int fini (void)
 This is an iterface function corresponding to the object moving back into IDLE state.
virtual int suspend (void)
 Temporarily suspend the execution of a service.
virtual int resume (void)
 Resume execution of a service.
virtual void init_service ()=0
 Interface function provided for derived classes as a place to initialize specifics of derived server.
virtual void process_events ()=0
 Interface function provided for derived classes as the main entry for data processing.
virtual void fatal_signal_hook ()
 Hook for derived class to do addition clean-up when terminating signal is delivered by OS.
int handle_signal (int signum_)
 Handle fatal signals.
bool service_is_active ()
 Normally called by the main loop to find out whether 'graceful quit' flag had been raised, signaling that some application's component requested to end data processing.
void stop_service ()
 Inform server that it has to stop data processing, clean up and exit.
void set_version (const string &release_, int revision_)
 Set Version and Revision number.
string get_version ()
 Obtain version information.
void set_author (const string &author_)
 Set author's name.
void set_flags (LogFlag logf_)
 New debug information is added to the old log file.
virtual void display_help ()
 List options and invocation syntax to stdout.
string get_proc_name ()
 Get name of process+instance_number.
void set_proc_name (string proc_name_)
 Change process name.
string get_cmdline_name ()
 Get command-line process name.
string get_default_config_file ()
 Get default configuration file name: $HOME/.
string get_config_file ()
 Get alternative configuration file name.
string get_port ()
 Return assumed name of the listening port.
void set_port (string port_)
 Set listening port name.
SigHandlersget_sig_manager ()
 Obtain reference to the Signal Manager, class SigHandls.
Reactorget_reactor ()
 Obtain reference to the Reactor.
int get_exit_value () const
 Retrieve exit value of the process.
- Public Member Functions inherited from ASSA::EventHandler
 EventHandler ()
 Constructor.
virtual ~EventHandler ()
 Virtual destructor.
virtual int handle_read (int fd)
 Read event callback.
virtual int handle_write (int fd)
 Write handler callback.
virtual int handle_except (int fd)
 Exception handler callback.
virtual int handle_timeout (TimerId tid)
 Timeout handler callback.
virtual int handle_close (int fd)
 EOF on peer socket handler callback.
virtual void resetState (void)
 A hook for derived class to reset internal state as needed.
void set_id (const std::string &id_)
 Set EventHandler ID.
std::string get_id () const
 Retrieve EventHandler ID.
- Public Member Functions inherited from ASSA::CmdLineOpts
 CmdLineOpts ()
 Default constructor.
virtual ~CmdLineOpts ()
 Do-nothing destructor.
bool add_flag_opt (const char c, const string &s, bool *f)
 Add binary flag option.
bool add_opt (const char c, const string &s, string *str)
 Add an option with STL string argument.
bool add_opt (const char c, const string &s, int *i)
 Add an option with integer argument.
bool add_opt (const char c, const string &s, unsigned int *ui)
 Add an option with unsigned integer argument.
bool add_opt (const char c, const string &s, long *l)
 Add an option with long argument.
bool add_opt (const char c, const string &s, unsigned long *ul)
 Add an option with unsigned long argument.
bool add_opt (const char c, const string &s, double *d)
 Add an option with double argument.
bool add_opt (const char c, const string &s, float *f)
 Add an option with float argument.
bool add_opt (const char c_, const string &s_, OPTS_FUNC f_)
 Add an option with static function argument.
bool add_opt (const char c_, const string &s_, OPTS_FUNC_ONE f_)
 Add an option with static function argument.
bool rm_opt (const char c_, const string &s_)
 Remove option for the option list.
bool parse_args (const char *argv[])
 Parse command line arguments based on installed options set.
int parse_config_file (IniFile &inifile_)
 Parse configuration parameters found in [options] section of the INI file.
const char * get_opt_error () const
 If previous call to one of member functions returned false, retrieve detailed error message.
void dump () const
 Write options set to the log file.

Static Public Member Functions

static bool become_daemon ()
 Become a daemon process.
- Static Public Member Functions inherited from ASSA::CmdLineOpts
static void str_to_argv (const string &src_, int &argc_, char **&argv_)
 Static function.
static void free_argv (char **&argv_)
 Free up memory allocated by str_to_argv() function.

Protected Member Functions

void set_exit_value (int v_)
 Set exit value of the process. This value is returned to the shell.
- Protected Member Functions inherited from ASSA::CmdLineOpts
bool is_valid (const char sopt_, const string &lopt_)
 Detect if supplied option is valid.
void set_error_none ()
 Reset error message to an empty string.
bool assign (Option *node_, const char *op_)
 Perform value assignment to the node.
Optionfind_option (const char *str_)
 Locate option in the options set.
Optionfind_option (const char letter_)
 Locate option in the options set.
virtual void pos_arg (const char *arg_)
 Process positional argument arg_.

Protected Attributes

string m_proc_name
 process name (considering instance_number)
string m_cmdline_name
 process name as appeared on command line
string m_port
 listening port name
string m_default_config_file
 standard configuration file name
string m_config_file
 alternative configuration file name
u_int m_log_size
 Max size of the log file.
int m_instance
 Process instance.
string m_log_file
 Full pathname of debug file.
string m_with_log_server
 If 'yes', send log messages to the log server.
string m_log_server
 Log server, assa-logd, address (port@host)
long m_mask
 Debug file mask to filter debug/error messages.
bool m_graceful_quit
 Flag that indicates wheather server outgh to stop and exit.
SigHandlers m_sig_dispatcher
 Signal handlers dispatcher.
SIGPOLLHandler m_sig_poll
 Function that swallows SIGPOLL calls.
Reactor m_reactor
 GenServer object has its very own personal Reactor object.
string m_version
 Software version.
int m_revision
 Software revision (patch) level.
string m_author
 Author's name.
const char * m_help_msg
 Help information.
LogFlag m_log_flag
 Log file initialization flag. If RM_LOG, remove old log file.
string m_log_stdout
 If 'yes', redirects all logging messages to std::cerr.
string m_daemon
 Daemon option flag. If 'yes', become a UNIX daemon process.
string m_ommit_pidfile
 If 'yes', skip PID file locking creation/locking step.
int m_log_level
 Logging level - an integer number that incrementally increases verbosity of the looing messages.
PidFileLock m_pidfile_lock
 PID File lock.
string m_pidfile
 PID File lock path name.
bool m_help_flag
 Help option flag.
bool m_version_flag
 Version option flag.
int m_exit_value
 Exit value of the process.
- Protected Attributes inherited from ASSA::EventHandler
std::string m_id

Private Member Functions

 GenServer (const GenServer &)
 No cloning.
GenServeroperator= (const GenServer &)
void init_internals ()
 Initialize internals.

Detailed Description

Definition at line 59 of file GenServer.h.


Member Enumeration Documentation

Enumerator:
KEEPLOG 

By default, append new log records to the existing log file.

This is operational mode.

RMLOG 

Remove existing log file and start afresh.

Convenient during development phase.

Definition at line 66 of file GenServer.h.

{
};

Constructor & Destructor Documentation

GenServer::GenServer ( )

Constructor.

Corresponds to the object entering the IDLE state.

Form a valid log server address

Definition at line 56 of file GenServer.cpp.

References ASSA::CmdLineOpts::add_flag_opt(), ASSA::CmdLineOpts::add_opt(), m_config_file, m_daemon, m_help_flag, m_instance, m_log_file, m_log_level, m_log_server, m_log_size, m_log_stdout, m_mask, m_ommit_pidfile, m_pidfile, m_port, m_version_flag, and m_with_log_server.

:
m_log_size (10485760), // 10 Mb
m_instance (-1),
m_log_server ("assalogd@"),
m_mask (ALL),
m_graceful_quit (false),
m_version ("unknown"),
m_author ("John Doe"),
m_help_msg ("No help available"),
m_log_stdout ("no"),
m_daemon ("no"),
m_help_flag (false),
m_version_flag (false),
{
add_flag_opt ('h', "help", &m_help_flag);
add_flag_opt ('v', "version", &m_version_flag);
add_opt ('d', "log-stdout", &m_log_stdout);
add_opt ('b', "daemon", &m_daemon);
add_opt ('L', "ommit-pidfile", &m_ommit_pidfile);
add_opt ('s', "with-log-server", &m_with_log_server);
add_opt ('m', "mask", &m_mask);
add_opt ('D', "log-file", &m_log_file);
add_opt ('f', "config-file", &m_config_file);
add_opt ('n', "instance", &m_instance);
add_opt ('p', "port", &m_port);
add_opt ('z', "log-size", &m_log_size);
add_opt ('l', "pidfile", &m_pidfile);
add_opt ('S', "log-server", &m_log_server);
add_opt ('c', "log-level", &m_log_level);
char hn[64];
::gethostname (hn, sizeof (hn)-1);
m_log_server += hn;
}
GenServer::~GenServer ( )
virtual

Destructor.

Reactor needs to detach itself from the Logger before releasing memory.

Otherwise, a race condition between Logger (singleton) and GenServer (singleton) might yield core dump if Reactor was destroyed before Logger. Since Reactor is attached to the Logger with Logger::log_open () for the assa-logd connection, it is Reactor's responsibility to detach first. But, we only care about GenServer's Reactor. All others (such as those used by Connector and Acceptor classes) should not.

Definition at line 112 of file GenServer.cpp.

References ASSA::Log::log_close().

ASSA::GenServer::GenServer ( const GenServer )
private

No cloning.


Member Function Documentation

bool GenServer::become_daemon ( )
static

Become a daemon process.

Definition at line 358 of file GenServer.cpp.

References ASSA::Fork::IGNORE_STATUS, ASSA::Fork::isChild(), and ASSA::Fork::LEAVE_ALONE.

Referenced by init().

{
#if defined(WIN32)
return true;
#else
if (!f.isChild ()) { // parent exits
exit (0);
}
int size = 1024;
int i = 0;
pid_t nullfd;
for (i = 0; i < size; i++) {
(void) close (i);
}
nullfd = open ("/dev/null", O_WRONLY | O_CREAT, 0666);
if (nullfd == -1) {
syslog (LOG_ERR,"failed to open \"/dev/null\"");
return false;
}
(void) dup2 (nullfd, 1);
(void) dup2 (nullfd, 2);
(void) close (nullfd);
if ( setsid() == -1 ) {
syslog (LOG_ERR,"setsid() failed");
return false;
}
/*---
Changing to root directory would be the right thing to do for a
server (so that it wouldn't possibly depend on any mounted file
systems. But, in practice, it might cause a lot of problems.
---*/
#if 0
if ( chdir("/") == -1 ) {
return false;
}
#endif
return (true);
#endif // defined(WIN32)
}
void ASSA::GenServer::display_help ( )
inlinevirtual

List options and invocation syntax to stdout.

Definition at line 375 of file GenServer.h.

References ASSA::endl(), m_author, and m_help_msg.

Referenced by init().

{
std::cout << m_help_msg << '\n'
<< "Written by " << m_author << "\n" << std::endl;
}
virtual void ASSA::GenServer::fatal_signal_hook ( )
inlinevirtual

Hook for derived class to do addition clean-up when terminating signal is delivered by OS.

Note that signal handling is provided by default and no additional intervention is necessary. Use this method only to enhance it.

Definition at line 135 of file GenServer.h.

Referenced by handle_signal().

{ /*--- empty ---*/ }
virtual int ASSA::GenServer::fini ( void  )
inlinevirtual

This is an iterface function corresponding to the object moving back into IDLE state.

Derived class is expected to perform actions that terminate execution of the service.

Definition at line 107 of file GenServer.h.

{ return 0; }
string ASSA::GenServer::get_cmdline_name ( )
inline

Get command-line process name.

Definition at line 190 of file GenServer.h.

References m_cmdline_name.

Referenced by init_internals().

{ return m_cmdline_name; }
string ASSA::GenServer::get_config_file ( )
inline

Get alternative configuration file name.

This name is specified as command-line argument '-f'

Definition at line 203 of file GenServer.h.

References m_config_file.

{ return m_config_file; }
string ASSA::GenServer::get_default_config_file ( )
inline

Get default configuration file name: $HOME/.

{command_line_name}.cfg If you want your configuration file name to be different, change the value of m_std_config_name in derived class

Definition at line 198 of file GenServer.h.

References m_default_config_file.

int ASSA::GenServer::get_exit_value ( ) const
inline

Retrieve exit value of the process.

Definition at line 227 of file GenServer.h.

References m_exit_value.

{ return m_exit_value; }
string ASSA::GenServer::get_port ( )
inline

Return assumed name of the listening port.

Definition at line 206 of file GenServer.h.

References m_port.

{ return m_port; }
string ASSA::GenServer::get_proc_name ( )
inline

Get name of process+instance_number.

Definition at line 182 of file GenServer.h.

References m_proc_name.

Referenced by init_internals().

{ return m_proc_name; }
Reactor* ASSA::GenServer::get_reactor ( )
inline

Obtain reference to the Reactor.

Definition at line 221 of file GenServer.h.

References m_reactor.

Referenced by handle_signal(), and init_internals().

{ return &m_reactor; }
SigHandlers& ASSA::GenServer::get_sig_manager ( )
inline

Obtain reference to the Signal Manager, class SigHandls.

Definition at line 216 of file GenServer.h.

References m_sig_dispatcher.

{ return m_sig_dispatcher; }
string ASSA::GenServer::get_version ( )
inline

Obtain version information.

Definition at line 366 of file GenServer.h.

References ASSA::ends(), m_revision, and m_version.

Referenced by init().

{
std::ostringstream v;
v << "Version: " << m_version << " Revision: " << m_revision << std::ends;
return (v.str ());
}
int GenServer::handle_signal ( int  signum_)
virtual

Handle fatal signals.

Hook (e.g. fatalSignalHook) is provided if derived class needs extra work before falling dead.

Reimplemented from ASSA::EventHandler.

Definition at line 409 of file GenServer.cpp.

References ASSA::APP, ASSA::Reactor::deactivate(), DL, ASSA::ends(), fatal_signal_hook(), get_reactor(), m_graceful_quit, and trace.

{
trace("GenServer::handle_signal");
std::ostringstream m;
switch (signum_)
{
case SIGTERM: m << "SIGTERM signal caugth. "; break;
case SIGINT: m << "SIGINT signal caugth. "; break;
default: m << "Unexpected signal caugth.";
}
m << "Signal # " << signum_ << std::ends;
DL((APP,"%s\n", m.str ().c_str () ));
DL((APP,"Initiating shutdown sequence...\n"));
DL((APP, "Shutdown sequence completed - Exiting !\n"));
/* Calling stop_service () triggers a call to Reactor::stopReactor()
with subsequent call to Reactor::removeIOHandler() and then
EventHandler::handle_close(). If EventHandler is in the middle
of the *slow* system call such as read(2), handle_close() will
destry EventHandler, and after cotrol is returned from
GenServer::handle_signal(), *slow* system call is restarted
and proceeds to operate on the memory that has been deleted already.
Calling Reactor::deactivate() instead delays memory release.
*/
return 0;
}
void GenServer::init ( int *  argc,
char *  argv[],
const char *  help_info 
)
virtual

Provide an entry point into the service and perfom initialization of the service.

Open log file and log startup options. Process standard command-line arguments. Following signals are handled in uniform manner: SIGHUP, SIGPIPE, SIGCHLD, SIGCLD, SIGALRM, SIGINT, SIGPOLL, SIGTERM.

This function corresponds to the object moving from IDLE to RUNNING state as result of service initialization, or reconfiguration of the service and remaining in RUNNING state.

Parameters:
argcPointer to number of command line arguments
argvCommand line arguments char* array
help_infoTitle that will be displayed with -h option
   Solaris x86 whole path is returned. 
   Scan through the path and get the process name. 


Convert relative paths of all filepath options to 
    absolute paths.


Daemonize the process if asked


Setting defaults if required 


Setup signal handling. 
    Ignore SIGHUP, SIGPIPE, SIGCHLD, SIGCLD, SIGALRM by default.
   SIGHUP is generated by terminal driver (see termio(7I) for
   details) in response to modem hangup (or closing terminal
   session). I ignore it here with the assumption that GenServer
   is alway a daemon process that doesn't have associated 
   controlling terminal anyway.
   Catch SIGPOLL - sigPOLL handler just does nothing except
   of catching signal.
   SIGINT is generated by the terminal driver when an interrupt
   key is pressed (DELETE or Ctrl-C). It is sent to all processes
   associated with the controlling terminal. We terminate process
   in this case.
   Catch and handle SIGTERM signals. 
   is the termination signal sent by kill command by default
   or internally as a part of fatal application exception handling 
   to properly terminate GenServer process. 
Initialize other internal stuff.

Definition at line 124 of file GenServer.cpp.

References ASSA_DIR_SEPARATOR, ASSAIOSIG, become_daemon(), display_help(), ASSA::endl(), ASSA::CmdLineOpts::get_opt_error(), get_version(), init_internals(), ASSA::SigHandlers::install(), m_author, m_cmdline_name, m_config_file, m_daemon, m_default_config_file, m_help_flag, m_help_msg, m_instance, m_log_file, m_pidfile, m_port, m_proc_name, m_sig_dispatcher, m_sig_poll, m_version_flag, ASSA::CmdLineOpts::parse_args(), ASSA::SigAction::register_action(), and ASSA::Utils::strenv().

{
char* cp = argv [0];
m_help_msg = ht_;
if (strchr(cp, ASSA_DIR_SEPARATOR)) {
cp += strlen(argv[0]); // position at the end
while (*cp-- != ASSA_DIR_SEPARATOR) {
;
}
cp += 2;
}
#if defined (WIN32) // get rid of '.exe'
char* extidx = cp;
while (*extidx) {
if (*extidx == '.') {
*extidx = '\0';
break;
}
extidx++;
}
#endif
if (!parse_args ((const char **)argv)) {
std::cerr << "Error in arguments: " << get_opt_error () << std::endl;
std::cerr << "Try '" << argv[0] << " --help' for details.\n";
exit (1);
}
if (m_help_flag) {
exit (0);
}
std::cerr << '\n' << argv[0] << " " << get_version () << '\n' << '\n'
<< "Written by " << m_author << "\n\n";
exit (0);
}
std::string s;
if (m_default_config_file.size ()) {
}
if (m_config_file.size ()) {
}
if (m_log_file.size ()) {
}
if (m_pidfile.size ()) {
m_pidfile = s;
}
if (m_daemon == "yes") {
assert(become_daemon ());
}
char instbuf[16]; // INT_MAX [-]2147483647
sprintf(instbuf, "%d", m_instance);
if (m_proc_name.length() == 0) {
if (m_instance != -1) {
m_proc_name += instbuf;
}
}
if (m_port.length() == 0) {
}
#if !defined(WIN32)
SigAction ignore_act( SIG_IGN );
ignore_act.register_action( SIGHUP );
ignore_act.register_action( SIGPIPE );
ignore_act.register_action( SIGCHLD );
#if !(defined (__FreeBSD__) || defined(__FreeBSD_kernel__) \
|| defined (__NetBSD__))
ignore_act.register_action( SIGCLD );
#endif
ignore_act.register_action( SIGALRM );
m_sig_dispatcher.install ( SIGINT, (EventHandler*) this );
m_sig_dispatcher.install ( SIGTERM, (EventHandler*) this );
#endif // !defined(WIN32)
}
void GenServer::init_internals ( )
private

Initialize internals.

Set standard configuration file name. For POSIX systems, it is $HOME/.procname. For Win32, it is $cwd/procname.ini.

Remove existing log file if requested. Unlinking /dev/null character device and replacing it with a regular file leads to the system crash during consecutive reboots. See also assa/FileLogger.cpp.

Open logging facility:

&ndash;log-stdout="yes" takes precedence over 
&ndash;with-log-server="yes" which takes precedence over 
&ndash;log-file=/path/to/log

Definition at line 271 of file GenServer.cpp.

References ASSA::APP, ASSA::ASSAERR, DL, ASSA::CmdLineOpts::dump(), get_cmdline_name(), ASSA::PidFileLock::get_error_msg(), get_proc_name(), get_reactor(), ASSA::PidFileLock::lock(), m_cmdline_name, m_config_file, m_default_config_file, m_log_file, m_log_flag, m_log_server, m_log_size, m_log_stdout, m_mask, m_ommit_pidfile, m_pidfile, m_pidfile_lock, m_proc_name, m_with_log_server, ASSA::Log::open_log_file(), ASSA::Log::open_log_server(), ASSA::Log::open_log_stdout(), RMLOG, ASSA::Log::set_app_name(), ASSA::Utils::strenv(), and trace.

Referenced by init().

{
static const char self[] = "GenServer::init_internals";
#if defined (WIN32)
#else
m_default_config_file = "$HOME/." + this->get_cmdline_name ();
#endif
if (m_log_flag == RMLOG && m_log_stdout == "no")
{
struct stat fst;
if (::stat (m_log_file.c_str(), &fst) == 0)
{
if (S_ISREG (fst.st_mode)) {
::unlink (m_log_file.c_str());
}
}
}
if (m_log_stdout == "yes") {
}
else {
if (m_with_log_server == "yes") {
m_log_file.c_str(),
}
else {
}
}
trace(self);
if (m_ommit_pidfile == "no")
{
if (m_pidfile.size () == 0) {
string s ("~/." + m_proc_name + ".pid");
}
DL((ASSAERR,"Failed to lock PID file: %s\n",
exit (1);
}
}
DL((APP,"\n" ));
DL((APP,"========================================================\n"));
DL((APP,"|| Server configuration settings ||\n"));
DL((APP,"========================================================\n"));
DL((APP," cmd_line_name = '%s'\n", m_cmdline_name.c_str() ));
DL((APP," name = '%s'\n", m_proc_name.c_str() ));
DL((APP," default config file = '%s'\n", m_default_config_file.c_str()));
DL((APP," config file = '%s'\n", m_config_file.c_str() ));
DL((APP," mask = 0x%X\n", m_mask ));
dump ();
DL((APP,"========================================================\n"));
DL((APP,"\n"));
}
virtual void ASSA::GenServer::init_service ( )
pure virtual

Interface function provided for derived classes as a place to initialize specifics of derived server.

GenServer& ASSA::GenServer::operator= ( const GenServer )
private
virtual void ASSA::GenServer::process_events ( )
pure virtual

Interface function provided for derived classes as the main entry for data processing.

This is the place to implement main event loop.

virtual int ASSA::GenServer::resume ( void  )
inlinevirtual

Resume execution of a service.

Corresponds to the process returning back to RUNNING state from SUSPENDED state.

Definition at line 117 of file GenServer.h.

{ return 0; }
bool ASSA::GenServer::service_is_active ( )
inline

Normally called by the main loop to find out whether 'graceful quit' flag had been raised, signaling that some application's component requested to end data processing.

Returns:
true when active; false if 'graceful quit' flag has been raised;

Definition at line 149 of file GenServer.h.

References m_graceful_quit.

{ return (!m_graceful_quit); }
void ASSA::GenServer::set_author ( const string &  author_)
inline

Set author's name.

Definition at line 359 of file GenServer.h.

References m_author.

{
m_author = author_;
}
void ASSA::GenServer::set_exit_value ( int  v_)
inlineprotected

Set exit value of the process. This value is returned to the shell.

Definition at line 231 of file GenServer.h.

References m_exit_value.

{ m_exit_value = v_; }
void ASSA::GenServer::set_flags ( LogFlag  logf_)
inline

New debug information is added to the old log file.

To erase old log file, set flag to RMLOG.

Parameters:
logf_Defaulted to KEEPLOG that adds log records to the existing log file; RMLOG - remove existing log file and start afresh.

Definition at line 176 of file GenServer.h.

References m_log_flag.

{ m_log_flag = logf_; }
void ASSA::GenServer::set_port ( string  port_)
inline

Set listening port name.

Parameters:
port_new listening port name

Definition at line 211 of file GenServer.h.

References m_port.

{ m_port = port_; }
void ASSA::GenServer::set_proc_name ( string  proc_name_)
inline

Change process name.

Parameters:
proc_name_new process name

Definition at line 187 of file GenServer.h.

References m_proc_name.

{ m_proc_name = proc_name_; }
void ASSA::GenServer::set_version ( const string &  release_,
int  revision_ 
)
inline

Set Version and Revision number.

Parameters:
release_Release number.
revision_Patch level.

Definition at line 351 of file GenServer.h.

References m_revision, and m_version.

{
m_version = release_;
m_revision = revision_;
}
void ASSA::GenServer::stop_service ( )
inline

Inform server that it has to stop data processing, clean up and exit.

This method will also stop internal Reactor.

Definition at line 343 of file GenServer.h.

References ASSA::Reactor::deactivate(), m_graceful_quit, and m_reactor.

virtual int ASSA::GenServer::suspend ( void  )
inlinevirtual

Temporarily suspend the execution of a service.

Corresponds to process leaving RUNNING state and entering SUSPENDED state.

Definition at line 112 of file GenServer.h.

{ return 0; }

Member Data Documentation

string ASSA::GenServer::m_author
protected

Author's name.

Definition at line 289 of file GenServer.h.

Referenced by display_help(), init(), and set_author().

string ASSA::GenServer::m_cmdline_name
protected

process name as appeared on command line

Definition at line 238 of file GenServer.h.

Referenced by get_cmdline_name(), init(), and init_internals().

string ASSA::GenServer::m_config_file
protected

alternative configuration file name

Definition at line 247 of file GenServer.h.

Referenced by GenServer(), get_config_file(), init(), and init_internals().

string ASSA::GenServer::m_daemon
protected

Daemon option flag. If 'yes', become a UNIX daemon process.

Definition at line 301 of file GenServer.h.

Referenced by GenServer(), and init().

string ASSA::GenServer::m_default_config_file
protected

standard configuration file name

Definition at line 244 of file GenServer.h.

Referenced by get_default_config_file(), init(), and init_internals().

int ASSA::GenServer::m_exit_value
protected

Exit value of the process.

Definition at line 329 of file GenServer.h.

Referenced by get_exit_value(), and set_exit_value().

bool ASSA::GenServer::m_graceful_quit
protected

Flag that indicates wheather server outgh to stop and exit.

Definition at line 269 of file GenServer.h.

Referenced by handle_signal(), service_is_active(), and stop_service().

bool ASSA::GenServer::m_help_flag
protected

Help option flag.

If true, [-h, –help] option is being specified on command line.

Definition at line 321 of file GenServer.h.

Referenced by GenServer(), and init().

const char* ASSA::GenServer::m_help_msg
protected

Help information.

Definition at line 292 of file GenServer.h.

Referenced by display_help(), and init().

int ASSA::GenServer::m_instance
protected

Process instance.

Definition at line 253 of file GenServer.h.

Referenced by GenServer(), and init().

string ASSA::GenServer::m_log_file
protected

Full pathname of debug file.

Definition at line 256 of file GenServer.h.

Referenced by GenServer(), init(), and init_internals().

LogFlag ASSA::GenServer::m_log_flag
protected

Log file initialization flag. If RM_LOG, remove old log file.

Definition at line 295 of file GenServer.h.

Referenced by init_internals(), and set_flags().

int ASSA::GenServer::m_log_level
protected

Logging level - an integer number that incrementally increases verbosity of the looing messages.

The exact meaning of each level is application-specific.

Definition at line 310 of file GenServer.h.

Referenced by GenServer().

string ASSA::GenServer::m_log_server
protected

Log server, assa-logd, address (port@host)

Definition at line 263 of file GenServer.h.

Referenced by GenServer(), and init_internals().

u_int ASSA::GenServer::m_log_size
protected

Max size of the log file.

Definition at line 250 of file GenServer.h.

Referenced by GenServer(), and init_internals().

string ASSA::GenServer::m_log_stdout
protected

If 'yes', redirects all logging messages to std::cerr.

Definition at line 298 of file GenServer.h.

Referenced by GenServer(), and init_internals().

long ASSA::GenServer::m_mask
protected

Debug file mask to filter debug/error messages.

Definition at line 266 of file GenServer.h.

Referenced by GenServer(), and init_internals().

string ASSA::GenServer::m_ommit_pidfile
protected

If 'yes', skip PID file locking creation/locking step.

Definition at line 304 of file GenServer.h.

Referenced by GenServer(), and init_internals().

string ASSA::GenServer::m_pidfile
protected

PID File lock path name.

Definition at line 316 of file GenServer.h.

Referenced by GenServer(), init(), and init_internals().

PidFileLock ASSA::GenServer::m_pidfile_lock
protected

PID File lock.

Definition at line 313 of file GenServer.h.

Referenced by init_internals().

string ASSA::GenServer::m_port
protected

listening port name

Definition at line 241 of file GenServer.h.

Referenced by GenServer(), get_port(), init(), and set_port().

string ASSA::GenServer::m_proc_name
protected

process name (considering instance_number)

Definition at line 235 of file GenServer.h.

Referenced by get_proc_name(), init(), init_internals(), and set_proc_name().

Reactor ASSA::GenServer::m_reactor
protected

GenServer object has its very own personal Reactor object.

Definition at line 280 of file GenServer.h.

Referenced by get_reactor(), and stop_service().

int ASSA::GenServer::m_revision
protected

Software revision (patch) level.

Definition at line 286 of file GenServer.h.

Referenced by get_version(), and set_version().

SigHandlers ASSA::GenServer::m_sig_dispatcher
protected

Signal handlers dispatcher.

Definition at line 273 of file GenServer.h.

Referenced by get_sig_manager(), and init().

SIGPOLLHandler ASSA::GenServer::m_sig_poll
protected

Function that swallows SIGPOLL calls.

Definition at line 276 of file GenServer.h.

Referenced by init().

string ASSA::GenServer::m_version
protected

Software version.

Definition at line 283 of file GenServer.h.

Referenced by get_version(), and set_version().

bool ASSA::GenServer::m_version_flag
protected

Version option flag.

If true, [-v, –version] options is being specified on command line.

Definition at line 326 of file GenServer.h.

Referenced by GenServer(), and init().

string ASSA::GenServer::m_with_log_server
protected

If 'yes', send log messages to the log server.

Definition at line 259 of file GenServer.h.

Referenced by GenServer(), and init_internals().


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