techempower_microhttpd.cc 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include <silicon/backends/mhd.hh>
  2. #include "techempower.hh"
  3. using namespace s;
  4. using namespace sl;
  5. int main(int argc, char* argv[])
  6. {
  7. if (argc != 4)
  8. {
  9. std::cerr << "Usage: " << argv[0] << " mysql_host port nthreads" << std::endl;
  10. return 1;
  11. }
  12. auto techempower_middlewares = middleware_factories(
  13. mysql_connection_factory(argv[1], "benchmarkdbuser", "benchmarkdbpass", "hello_world"),
  14. fortune_orm_factory("Fortune"),
  15. rn_orm_factory("World")
  16. );
  17. try
  18. {
  19. // Write the pid.
  20. std::ofstream pidfile(argv[3]);
  21. pidfile << getpid() << std::endl;
  22. pidfile.close();
  23. // Start the server.
  24. sl::mhd_json_serve(techempower_api, techempower_middlewares, atoi(argv[2]), _blocking
  25. #ifdef TFB_USE_EPOLL
  26. , _linux_epoll, _nthreads = atoi(argv[3])
  27. #else
  28. , _one_thread_per_connection
  29. #endif
  30. );
  31. }
  32. catch (std::exception& e)
  33. {
  34. std::cerr << e.what() << std::endl;
  35. }
  36. catch (sl::error::error& e)
  37. {
  38. std::cerr << e.what() << std::endl;
  39. }
  40. }