Changeset 14189 for fact/Evidence


Ignore:
Timestamp:
06/19/12 09:59:14 (13 years ago)
Author:
ogrimm
Message:
If DIM_DNS_NODE not set, EvidenceServer tries to run in local mode, starting a dns as separate process on localhost
Location:
fact/Evidence
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • fact/Evidence/Evidence.cc

    r14174 r14189  
    102102  ExitRequest = false;
    103103  This = this;
     104  LocalMode = false;
    104105
    105106  dis_disable_padding();
     
    128129  // Catch C++ unhandled exceptions
    129130  set_terminate(Terminate);
     131
     132  // If name server node not set, use localhost and launch dns
     133  if (getenv("DIM_DNS_NODE") == NULL) {
     134        printf("Environment variable DIM_DNS_NODE not set, will run in local mode. One moment please...\n");
     135
     136        if (setenv("DIM_DNS_NODE", "localhost", 0) == -1) {
     137          printf("setenv() failed in EvidenceServer::EvidenceServer (%s)\n", strerror(errno));
     138        }
     139        else LocalMode = true;
     140       
     141        // Launch dns in a separate process (currently no further checks to avoid zombie generation)
     142        if ((ChildPID = fork()) == 0) {
     143          if (execlp("dns", "dns", (char *) NULL) == -1) {
     144                printf("execlp() failed in child process forked in EvidenceServer::EvidenceServer() (%s)\n", strerror(errno));
     145                exit(EXIT_FAILURE);
     146          }
     147        }
     148        if (ChildPID == -1) printf("fork() failed in EvidenceServer::EvidenceServer() (%s)\n", strerror(errno));
     149
     150        // Wait for dns to become active
     151        sleep(3);
     152  }
    130153
    131154  // Message service and initial message
     
    272295        // Check if successful
    273296        if (!EvidenceServer::ServiceOK(&Config)) {
    274       if (Default.empty()) {
     297      if (Default.empty() && !LocalMode) {
    275298                Message(FATAL, "Configuration server unreachable, can't retrieve '%s'", Item.c_str());
    276299          }
     
    306329
    307330  // Terminate if no configuration information found
    308   if (Result.empty()) Message(FATAL, "Missing configuration data '%s'", Item.c_str());
     331  if (Result.empty() && !LocalMode) Message(FATAL, "Missing configuration data '%s'", Item.c_str());
    309332
    310333  return Result;
  • fact/Evidence/Evidence.h

    r12910 r14189  
    6161        static pthread_mutex_t Mutex;
    6262        static EvidenceServer *This;
     63        bool LocalMode;
     64        pid_t ChildPID;
    6365
    6466    static void SignalHandler(int); // static for signal()
  • fact/Evidence/readme.txt

    r14187 r14189  
    676713/6/2012       Removed calling Message() before abort() in signal handler, as Message() might get stuck
    686819/6/2012   Giving no indices in OpenHistory() will try to open plot for all members of an array
     69                        If DIM_DNS_NODE not set, EvidenceServer will run in local mode, launching a dns in a separate process on localhost
Note: See TracChangeset for help on using the changeset viewer.