crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs | LICENSE

init.cc (918B)


      1 #include "balancer"
      2 
      3 void Balancer::init() {
      4     // Set the listening socket.
      5     if (! config.sport()) {
      6 	// In inetd mode, set the server socket to fd 0.
      7 	// Else it will be initialized.
      8 	server_fd.fd(0);
      9     } else {
     10 	// In TCP mode: Prepare the binding.
     11 	server_fd.bind(config.sipaddr(), config.sport());
     12     }
     13     
     14     // Start the web interface if requested.
     15     if (config.usewebinterface() && !config.foregroundmode()) {
     16 	webinterface = new Webinterface();
     17 	if (! webinterface)
     18 	    throw Error("Memory fault in Balancer::init");
     19 	webinterface->start();
     20     }
     21 
     22     // Add workable back ends, display initial states.
     23     for (int i = 0; i < config.backends(); i++) 
     24 	addbackend (config.backend(i));
     25     msg("Back end start states of " << nbackends() << " backends:\n");
     26     for (unsigned i = 0; i < nbackends(); i++) 
     27 	msg(' ' << backend(i).description() << " is " <<
     28 	    backend(i).availablestr() << '\n');
     29 }