comparison OrthancServer/main.cpp @ 1102:ce6386b37afd

avoid unnecessary exceptions on Orthanc startup
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 07 Aug 2014 10:51:35 +0200
parents bb82e5e818e9
children bec1eccf976c
comparison
equal deleted inserted replaced
1101:e5686a703c63 1102:ce6386b37afd
371 } 371 }
372 } 372 }
373 373
374 google::InitGoogleLogging("Orthanc"); 374 google::InitGoogleLogging("Orthanc");
375 375
376 const char* configurationFile = NULL;
377 for (int i = 1; i < argc; i++)
378 {
379 // Use the first argument that does not start with a "-" as
380 // the configuration file
381 if (argv[i][0] != '-')
382 {
383 configurationFile = argv[i];
384 }
385 }
386
387
376 int status = 0; 388 int status = 0;
377 try 389 try
378 { 390 {
379 bool isInitialized = false; 391 OrthancInitialize(configurationFile);
380 if (argc >= 2)
381 {
382 for (int i = 1; i < argc; i++)
383 {
384 // Use the first argument that does not start with a "-" as
385 // the configuration file
386 if (argv[i][0] != '-')
387 {
388 OrthancInitialize(argv[i]);
389 isInitialized = true;
390 }
391 }
392 }
393
394 if (!isInitialized)
395 {
396 OrthancInitialize();
397 }
398 392
399 std::string storageDirectoryStr = Configuration::GetGlobalStringParameter("StorageDirectory", "OrthancStorage"); 393 std::string storageDirectoryStr = Configuration::GetGlobalStringParameter("StorageDirectory", "OrthancStorage");
400 boost::filesystem::path storageDirectory = Configuration::InterpretStringParameterAsPath(storageDirectoryStr); 394 boost::filesystem::path storageDirectory = Configuration::InterpretStringParameterAsPath(storageDirectoryStr);
401 boost::filesystem::path indexDirectory = Configuration::InterpretStringParameterAsPath( 395 boost::filesystem::path indexDirectory = Configuration::InterpretStringParameterAsPath(
402 Configuration::GetGlobalStringParameter("IndexDirectory", storageDirectoryStr)); 396 Configuration::GetGlobalStringParameter("IndexDirectory", storageDirectoryStr));