PageRenderTime 41ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/demo/src/yolk_demo.adb

http://github.com/ThomasLocke/yolk
Ada | 70 lines | 32 code | 9 blank | 29 comment | 0 complexity | 7d038e7d6ca8047458582e4aea2d213e MD5 | raw file
Possible License(s): AGPL-1.0
  1. -------------------------------------------------------------------------------
  2. -- --
  3. -- Copyright (C) 2010-, Thomas ¸cke --
  4. -- --
  5. -- This is free software; you can redistribute it and/or modify it --
  6. -- under terms of the GNU General Public License as published by the --
  7. -- Free Software Foundation; either version 3, or (at your option) any --
  8. -- later version. This library is distributed in the hope that it will be --
  9. -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
  10. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
  11. -- You should have received a copy of the GNU General Public License and --
  12. -- a copy of the GCC Runtime Library Exception along with this program; --
  13. -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
  14. -- <http://www.gnu.org/licenses/>. --
  15. -- --
  16. -------------------------------------------------------------------------------
  17. -- Feel free to use this demo application as the foundation for your own
  18. -- applications.
  19. --
  20. -- Usually you just have to change the name of environment task and the name
  21. -- of the file itself to match whatever you want to call your application.
  22. with Ada.Exceptions;
  23. with My_Handlers;
  24. with Websocket_Demo;
  25. with Yolk.Configuration;
  26. with Yolk.Log;
  27. with Yolk.Process_Control;
  28. with Yolk.Process_Owner;
  29. with Yolk.Server;
  30. with Yolk.Whoops;
  31. procedure Yolk_Demo is
  32. use Ada.Exceptions;
  33. use Yolk.Configuration;
  34. use Yolk.Log;
  35. use Yolk.Process_Control;
  36. use Yolk.Process_Owner;
  37. use Yolk.Server;
  38. Web_Server : HTTP := Create
  39. (Unexpected => Yolk.Whoops.Unexpected_Exception_Handler'Access);
  40. begin
  41. Set_User (Username => Config.Get (Yolk_User));
  42. -- Switch user.
  43. Web_Server.Start (Dispatchers => My_Handlers.Get);
  44. -- Start the HTTP server.
  45. Websocket_Demo.Start;
  46. -- Start the WebSocket demo.
  47. Wait;
  48. -- This is the main "loop". We will wait here as long as the
  49. -- Yolk.Process_Control.Controller.Check entry barrier is False.
  50. Web_Server.Stop;
  51. -- Stop the HTTP server.
  52. Websocket_Demo.Stop;
  53. -- Stop the WebSocket demo.
  54. exception
  55. when Event : others =>
  56. Trace (Handle => Error,
  57. Message => Exception_Information (Event));
  58. -- Write the exception information to the rotating Error log trace.
  59. Web_Server.Stop;
  60. Websocket_Demo.Stop;
  61. end Yolk_Demo;