delphimvcframework/unittests/general/TestServer/TestServer.dpr

87 lines
3.6 KiB
ObjectPascal
Raw Normal View History

program TestServer;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
IdHTTPWebBrokerBridge,
Web.WebReq,
2017-10-16 22:57:27 +02:00
{$IFNDEF LINUX}
2017-10-16 22:57:27 +02:00
Winapi.Windows,
2017-10-16 22:57:27 +02:00
2017-06-22 16:18:58 +02:00
{$ENDIF }
2017-10-16 22:57:27 +02:00
Web.WebBroker,
MVCFramework.Commons,
2017-10-16 22:57:27 +02:00
MVCFramework.Console,
WebModuleUnit in 'WebModuleUnit.pas' {bas: TWebModule} ,
TestServerControllerU in 'TestServerControllerU.pas',
TestServerControllerExceptionU in 'TestServerControllerExceptionU.pas',
SpeedMiddlewareU in 'SpeedMiddlewareU.pas',
TestServerControllerPrivateU in 'TestServerControllerPrivateU.pas',
AuthHandlersU in 'AuthHandlersU.pas',
2017-06-22 16:18:58 +02:00
BusinessObjectsU in '..\..\..\samples\commons\BusinessObjectsU.pas',
MVCFramework in '..\..\..\sources\MVCFramework.pas',
TestServerControllerJSONRPCU in 'TestServerControllerJSONRPCU.pas',
MVCFramework.JSONRPC in '..\..\..\sources\MVCFramework.JSONRPC.pas';
{$R *.res}
procedure Logo;
begin
2017-10-16 22:57:27 +02:00
SetMode(TConsoleMode.Bright);
TextBackground(TConsoleColor.Black);
TextColor(TConsoleColor.Red);
WriteLn(' ██████╗ ███╗ ███╗██╗ ██╗ ██████╗ ███████╗███████╗██████╗ ██╗ ██╗███████╗██████╗');
WriteLn(' ██╔══██╗████╗ ████║██║ ██║██╔════╝ ██╔════╝██╔════╝██╔══██╗██║ ██║██╔════╝██╔══██╗');
WriteLn(' ██║ ██║██╔████╔██║██║ ██║██║ ███████╗█████╗ ██████╔╝██║ ██║█████╗ ██████╔╝');
WriteLn(' ██║ ██║██║╚██╔╝██║╚██╗ ██╔╝██║ ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██╔══╝ ██╔══██╗');
WriteLn(' ██████╔╝██║ ╚═╝ ██║ ╚████╔╝ ╚██████╗ ███████║███████╗██║ ██║ ╚████╔╝ ███████╗██║ ██║');
WriteLn(' ╚═════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═════╝ ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝');
WriteLn(' ');
2017-10-16 22:57:27 +02:00
TextColor(TConsoleColor.Yellow);
WriteLn('DMVCFRAMEWORK VERSION: ', DMVCFRAMEWORK_VERSION);
2017-10-16 22:57:27 +02:00
TextColor(TConsoleColor.White);
end;
procedure RunServer(APort: Integer);
var
LServer: TIdHTTPWebBrokerBridge;
begin
Logo;
WriteLn(Format('Starting HTTP Server or port %d', [APort]));
LServer := TIdHTTPWebBrokerBridge.Create(nil);
try
LServer.DefaultPort := APort;
LServer.Active := True;
{ more info about MaxConnections
http://www.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=TIdCustomTCPServer_MaxConnections.html }
LServer.MaxConnections := 0;
{ more info about ListenQueue
http://www.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=TIdCustomTCPServer_ListenQueue.html }
LServer.ListenQueue := 200;
WriteLn('Press RETURN to stop the server');
ReadLn;
WriteLn('Server stopped');
finally
LServer.Free;
end;
end;
begin
ReportMemoryLeaksOnShutdown := True;
try
if WebRequestHandler <> nil then
WebRequestHandler.WebModuleClass := WebModuleClass;
RunServer(9999);
except
on E: Exception do
WriteLn(E.ClassName, ': ', E.Message);
end
end.