libzeep

PrevUpHomeNext

Class daemon

zeep::http::daemon — A class to create daemon processes easily.

Synopsis

// In header: <zeep/http/daemon.hpp>


class daemon {
public:
  // types
  typedef basic_server *()> ;  // The factory for creating server instances. 

  // construct/copy/destruct
  (, , , 
         );
  (, );

  // public member functions
   (, );
   (, , , , 
            );
   ();
   ();
   ();
   (, );

  // private member functions
   ();
   ();
   (, , , , 
                     );
   ();
};

Description

In UNIX a daemon is a process that runs in the background. In the case of libzeep this is of course serving HTTP requests. stderr and stdout are captured and written to the log files specified and a process ID is store in the pid file which allows checking the status of a running daemon.

daemon public construct/copy/destruct

  1. ( factory,  pid_file, 
            stdout_log_file, 
            stderr_log_file);
    constructor with separately specified files

    Parameters:

    factory

    The function object that creates server instances

    pid_file

    The file that will contain the process ID, usually in /var/run/<process_name>

    stderr_log_file

    The file that will contain the stderr log, usually in /var/log/<process_name>/error.log

    stdout_log_file

    The file that will contain the stdout log, usually in /var/log/<process_name>/access.log

  2. ( factory,  name);
    constructor with default files

    Parameters:

    factory

    The function object that creates server instances

    name

    The process name to use, will be used to form default file locations

daemon public member functions

  1.  ( nr_of_restarts,  within_nr_of_seconds);
    Avoid excessive automatic restart due to failing to start up.

    Parameters:

    nr_of_restarts

    The max number of attempts to take to start up a daemon process

    within_nr_of_seconds

    The restart counter will only consider a failed restart if it fails starting up within this period of time.

  2.  ( address,  port,  nr_of_procs, 
               nr_of_threads,  run_as_user);
    Start the daemon, forking off in the background.

    Parameters:

    address

    The address to bind to

    nr_of_threads

    The number of threads to pass to the server class

    port

    The port number to bind to

    run_as_user

    The user to run the forked process. Daemons are usually started as root and should drop their privileges as soon as possible.

  3.  ();
    Stop a running daemon process. Returns 0 in case of successfully stopping a process.
  4.  ();
    Returns 0 if the daemon is running.
  5.  ();
    Force the running daemon to restart.
  6.  ( address,  port);
    Run the server without forking to the background.

    For debugging purposes it is sometimes useful to start a server without forking so you can see the stdout and stderr. Often this is done by adding a –no-daemon flag to the program options.

daemon private member functions

  1.  ();
  2.  ();
  3.  ( address,  port, 
                        nr_of_procs,  nr_of_threads, 
                        run_as_user);
  4.  ();

PrevUpHomeNext