1.4. What's Under The Hood?

Let's examine HelloWorld class diagram:

Figure 1-1. HelloWorld Class Diagram

GenServer is an abstract class that requires derived classes to implement both initServer() and processServer() virtual functions.

GenServer is also a child of an abstract class EventHandler which enables GenServer to catch UNIX signals and process them as events. Such events would be, for example, SIGHUP generated by the user pressing Ctrl-C, or SIGTERM caused by killing the process. Class SigHandlers is responsible for catching the signal and informing class Reactor to deliver it to GenServer. The good news is that unless you want to take over the signal handling, the expected behavior is implemented in GenServer. Derived classes such as HelloWorld should not have to deal with it.

Class CmdLineOpts (see Section 4.4) is a placeholder for the most typical command-line arguments. You can adjust them by asking CmdLineOpts to remove existing arguments or add the new ones. You can see the list of arguments HelloWorld has been equipped with by default:

% ./HelloWorld --help
   Your application program name                                            
   Short description to give general feeling                                
   of what its main purpose is.                                             
   shell>  app_name [OPTIONS]                                               
 -b, --daemon            - Run process as true UNIX daemon                  
 -l, --pidfile PATH      - The process ID is written to the lockfile PATH   
                           instead of default ~/.{procname}.pid             
 -L, --no-pidfile        - Do not create PID lockfile                       
 -D, --log-file NAME     - Write debug to NAME file                         
 -d, --log-stdout        - Write debug to standard output                   
 -z, --log-size NUM      - Maximum size debug file can reach (dfl: is 10Mb) 
 -m, --mask MASK         - Mask (default: ALL = 0x7fffffff)                 
 -p, --port NAME         - The tcp/ip port NAME (default - procname)        
 -n, --instance NUM      - Process instance NUM (default - none)            
 -f, --config-file NAME  - Alternative configuration file NAME              
 -h, --help              - Print this messag                                
 -v, --version           - Print version number                            

Written by YOUR-NAME


As you can see, there are quite a few of them, but our little example has no use for most of these arguments. These arguments are the subject of the next section.