Example #1
0
int run_server(int args, char** argv, const std::string& type) {
  try {
    ImplServerClass impl_server(server_argv(args, argv, type));
    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) << e.diagnostic_information(true);
    return -1;
  }
}
Example #2
0
int run_server(int args, char** argv, const std::string& type) {
  try {
    ImplServerClass impl_server(server_argv(args, argv, type));

    impl_server.get_p()->get_mixer()->register_api(impl_server);
    ::atexit(jubatus::framework::atexit);

    jubatus::util::set_exit_on_term();
    jubatus::util::ignore_sigpipe();
    return impl_server.run();
  } catch (const jubatus::exception::jubatus_exception& e) {
    LOG(FATAL) << e.diagnostic_information(true);
    return -1;
  }
}
Example #3
0
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;
  }
}
Example #4
0
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;
  }
}
Example #5
0
int run_server(int args, char** argv){

  ImplServerClass impl_server(server_argv(args, argv));
#ifdef HAVE_ZOOKEEPER_H
  pfi::network::mprpc::rpc_server& serv = impl_server;
  serv.add<std::vector<std::string>(int)>
    ("get_diff",
     pfi::lang::bind(&UserServClass::get_diff_impl,
		     impl_server.get_p().get(), pfi::lang::_1));
  serv.add<int(std::vector<std::string>)>
    ("put_diff",
     pfi::lang::bind(&UserServClass::put_diff_impl,
		     impl_server.get_p().get(), pfi::lang::_1));
  serv.add<std::string(int)>
    ("get_storage",
     pfi::lang::bind(&UserServClass::get_storage,
		     impl_server.get_p().get(), pfi::lang::_1));

  set_exit_on_term();

#endif // HAVE_ZOOKEEPER_H
  return impl_server.run();
};