コード例 #1
0
ファイル: server_util.hpp プロジェクト: airtoxin/jubatus
int run_server(int args, char** argv, const std::string& type) {
  try {
    server_argv parsed_argv(args, argv, type);
    ImplServerClass impl_server(parsed_argv);
    if (!parsed_argv.is_standalone()) {
      impl_server.get_p()->get_mixer()->register_api(impl_server);
    }
    return impl_server.run();
  } catch (const jubatus::core::common::exception::jubatus_exception& e) {
    LOG(FATAL) << "exception in main thread: "
               << e.diagnostic_information(true);
    return -1;
  } catch (const std::exception& e) {
    LOG(FATAL) << "error in main thread: " << e.what();
    return -1;
  }
}
コード例 #2
0
ファイル: server_util.hpp プロジェクト: TkrUdagawa/jubatus
int run_server(int args, char** argv, const std::string& type) {
  try {
    server_argv parsed_argv(args, argv, type);
    if (parsed_argv.config_test) {
      try {
        jubatus::server::framework::server_helper<ServerClass> sh(parsed_argv);
      } catch (const jubatus::core::common::exception::jubatus_exception& e) {
        std::cerr << "Configuration error:" << std::endl
                  << e.diagnostic_information(true);
        return 1;
      }
      std::cerr << "Configuration OK" << std::endl;
      return 0;
    }

    ImplServerClass impl_server(parsed_argv);
    if (!parsed_argv.is_standalone()) {
      impl_server.get_p()->get_mixer()->register_api(impl_server);
    }
    return impl_server.run();
  } catch (const jubatus::core::common::exception::jubatus_exception& e) {
    if (common::logger::is_configured()) {
      LOG(FATAL) << "exception in main thread: "
                 << e.diagnostic_information(true);
    } else {
      std::cerr << "exception in main thread: "
                << e.diagnostic_information(true);
    }
    return -1;
  } catch (const std::exception& e) {
    if (common::logger::is_configured()) {
      LOG(FATAL) << "error in main thread: " << e.what();
    } else {
      std::cerr << "error in main thread: " << e.what();
    }
    return -1;
  }
}