techempower_lwan.cc 870 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include <silicon/backends/lwan.hh>
  2. #include "techempower.hh"
  3. using namespace s;
  4. using namespace sl;
  5. int main(int argc, char* argv[])
  6. {
  7. if (argc != 3)
  8. {
  9. std::cerr << "Usage: " << argv[0] << " mysql_host port" << 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::lwan_json_serve(techempower_api, techempower_middlewares, atoi(argv[2]));
  25. }
  26. catch (std::exception& e)
  27. {
  28. std::cerr << e.what() << std::endl;
  29. }
  30. catch (sl::error::error& e)
  31. {
  32. std::cerr << e.what() << std::endl;
  33. }
  34. }