app.d 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Collie - An asynchronous event-driven network framework using Dlang development
  3. *
  4. * Copyright (C) 2015-2018 Shanghai Putao Technology Co., Ltd
  5. *
  6. * Developer: Putao's Dlang team
  7. *
  8. * Licensed under the Apache-2.0 License.
  9. *
  10. */
  11. import std.getopt;
  12. import std.stdio;
  13. //import hunt.database;
  14. import hunt.io;
  15. import hunt.system.Memory : totalCPUs;
  16. import http.Processor;
  17. import http.Server;
  18. import http.DemoProcessor;
  19. void main(string[] args) {
  20. ushort port = 8080;
  21. GetoptResult o = getopt(args, "port|p", "Port (default 8080)", &port);
  22. if (o.helpWanted) {
  23. defaultGetoptPrinter("A simple http server powered by Hunt!", o.options);
  24. return;
  25. }
  26. //version (POSTGRESQL) {
  27. // DatabaseOption options;
  28. // debug {
  29. // options = new DatabaseOption(
  30. // "postgresql://benchmarkdbuser:[email protected]:5432/hello_world?charset=utf-8");
  31. // } else {
  32. // options = new DatabaseOption(
  33. // "postgresql://benchmarkdbuser:benchmarkdbpass@tfb-database:5432/hello_world?charset=utf-8");
  34. // }
  35. //
  36. // options.setMinimumConnection(totalCPUs*3);
  37. // options.setMaximumConnection(totalCPUs*3);
  38. // dbConnection = new Database(options);
  39. //}
  40. AbstractTcpServer httpServer = new HttpServer!(DemoProcessor)("0.0.0.0", port, totalCPUs);
  41. writefln("listening on http://%s", httpServer.bindingAddress.toString());
  42. httpServer.start();
  43. }