MCPcopy Create free account
hub / github.com/SNAS/openbmp / main

Function main

Server/src/openbmp.cpp:556–625  ·  view source on GitHub ↗

* main function */

Source from the content-addressed store, hash-verified

554 * main function
555 */
556int main(int argc, char **argv) {
557 Config cfg;
558
559 // Process the command line args
560 if (ReadCmdArgs(argc, argv, cfg)) {
561 return 1;
562 }
563
564 if (cfg_filename != NULL) {
565 try {
566 cfg.load(cfg_filename);
567
568 } catch (char const *str) {
569 cout << "ERROR: Failed to load the configuration file: " << str << endl;
570 return 2;
571 }
572 }
573
574 // Make sure we have the required ARGS
575 if (strlen(cfg.admin_id) <= 0) {
576 cout << "ERROR: Missing required 'admin ID', use -c <config> or -a <string> to set the collector admin ID" << endl;
577 return 2;
578 }
579
580 try {
581 // Initialize logging
582 logger = new Logger(log_filename, debug_filename);
583 } catch (char const *str) {
584 cout << "Failed to open log file for read/write : " << str << endl;
585 return 2;
586 }
587
588 // Set up defaults for logging
589 logger->setWidthFilename(15);
590 logger->setWidthFunction(18);
591
592 if (cfg.debug_general)
593 logger->enableDebug();
594
595 else if (not run_foreground){
596 /*
597 * Become a daemon if debug is not enabled
598 */
599 daemonize();
600 }
601
602 /*
603 * Setup the signal handlers
604 */
605 struct sigaction sigact;
606 sigact.sa_handler = signal_handler;
607 sigact.sa_flags = 0;
608 sigemptyset( &sigact.sa_mask); // blocked signals while handler runs
609
610 sigaction(SIGCHLD, &sigact, NULL);
611 sigaction(SIGHUP, &sigact, NULL);
612 sigaction(SIGTERM, &sigact, NULL);
613 sigaction(SIGPIPE, &sigact, NULL);

Callers

nothing calls this directly

Calls 8

ReadCmdArgsFunction · 0.85
daemonizeFunction · 0.85
sigactionClass · 0.85
runServerFunction · 0.85
loadMethod · 0.80
setWidthFilenameMethod · 0.80
setWidthFunctionMethod · 0.80
enableDebugMethod · 0.45

Tested by

no test coverage detected