/usr/share/doc/libaws-doc/examples/runme/runme_service.adb is in libaws-doc 3.3.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2000-2012, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This software is distributed in the hope that it will --
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public License --
-- distributed with this software; see file COPYING3. If not, go --
-- to http://www.gnu.org/licenses for a complete copy of the license. --
------------------------------------------------------------------------------
with Ada.Exceptions;
with Ada.Text_IO;
with GNAT.Directory_Operations;
with Service.Status;
with SSL;
with AWS.Server.Log;
pragma Elaborate_All (AWS.Server);
with AWS.Log;
with Runme_CB;
package body Runme_Service is
use Ada;
use Ada.Exceptions;
use GNAT;
Stop_Request : Boolean := False;
pragma Atomic (Stop_Request);
Running : Boolean := False;
pragma Atomic (Running);
WSS : AWS.Server.HTTP;
WS : AWS.Server.HTTP;
Output : Text_IO.File_Type;
----------
-- Stop --
----------
procedure Stop is
begin
Stop_Request := True;
AWS.Server.Shutdown (WS);
AWS.Server.Shutdown (WSS);
AWS.Server.Log.Stop (WS);
Text_IO.Close (Output);
Running := False;
Service.Status.Set
(Target => Server.Status,
New_State => Service.Status.Stopped_State);
end Stop;
-----------------
-- Interrogate --
-----------------
procedure Interrogate is
begin
if Running then
Service.Status.Set
(Target => Server.Status,
New_State => Service.Status.Run_State);
else
Service.Status.Set
(Target => Server.Status,
New_State => Service.Status.Stopped_State);
end if;
end Interrogate;
----------
-- Main --
----------
procedure Main is
begin
-- Change to the right directory
Directory_Operations.Change_Dir (Runme_Info.Get_Executable_Path);
-- Set SSL certificate
AWS.Server.Set_Security
(WSS, Runme_Info.Get_Executable_Path & "\cert.pem");
-- All output goes to a log file
Text_IO.Create (Output, Text_IO.Out_File, "runme.service.log");
Text_IO.Set_Output (Output);
-- Update state
Service.Status.Set
(Target => Server.Status,
New_State => Service.Status.Run_State);
-- Start servers
Running := True;
AWS.Server.Start
(WSS, "Runme Secure",
Runme_CB.Service_Sec'Access,
Max_Connection => 3, Port => 4433, Security => True);
AWS.Server.Start
(WS, "Runme", Runme_CB.Service'Access,
3, "/Admin-Page", 1234, False, True);
AWS.Server.Log.Start (WS, Split_Mode => AWS.Log.Daily);
loop
delay 10.0;
exit when Stop_Request;
end loop;
exception
when E : others =>
Text_IO.Put_Line ("Service Error : " & Exception_Information (E));
Text_IO.Flush;
raise;
end Main;
end Runme_Service;
|