server_main.cc 892 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include <stdio.h>
  2. #include <signal.h>
  3. #include "workflow/WF%sServer.h"
  4. #include "workflow/WFFacilities.h"
  5. #include "config/util.h"
  6. #include "config/config.h"
  7. static WFFacilities::WaitGroup wait_group(1);
  8. static srpc::RPCConfig config;
  9. void sig_handler(int signo)
  10. {
  11. wait_group.done();
  12. }
  13. void init()
  14. {
  15. if (config.load("./server.conf") == false)
  16. {
  17. perror("Load config failed");
  18. exit(1);
  19. }
  20. signal(SIGINT, sig_handler);
  21. signal(SIGTERM, sig_handler);
  22. }
  23. void process(WF%sTask *task)
  24. {
  25. // delete the example codes and fill your logic
  26. %s
  27. }
  28. int main()
  29. {
  30. init();
  31. WF%sServer server(process);
  32. if (server.start(config.server_port()) == 0)
  33. {
  34. fprintf(stderr, "%s server started, port %%u\n", config.server_port());
  35. wait_group.wait();
  36. server.stop();
  37. }
  38. else
  39. perror("server start");
  40. return 0;
  41. }