delphimvcframework/samples/concurrency_speed_test/concurrency_speed_test.dpr

68 lines
1.8 KiB
ObjectPascal
Raw Normal View History

2019-05-19 14:06:12 +02:00
program concurrency_speed_test;
{$APPTYPE CONSOLE}
uses
2023-06-06 13:00:21 +02:00
RDPMM64,
2019-05-19 14:06:12 +02:00
System.SysUtils,
MVCFramework,
2019-05-19 14:06:12 +02:00
MVCFramework.Logger,
MVCFramework.DotEnv,
2019-05-19 14:06:12 +02:00
MVCFramework.Commons,
MVCFramework.Signal,
2019-05-19 14:06:12 +02:00
Web.ReqMulti,
Web.WebReq,
Web.WebBroker,
IdHTTPWebBrokerBridge,
MainControllerU in 'MainControllerU.pas',
WebModuleU in 'WebModuleU.pas' {MyWebModule: TWebModule};
{$R *.res}
procedure RunServer(APort: Integer);
var
lServer: TIdHTTPWebBrokerBridge;
begin
Writeln('** DMVCFramework Server ** build ' + DMVCFRAMEWORK_VERSION);
Writeln('Listening on port: ', APort);
2019-05-19 14:06:12 +02:00
lServer := TIdHTTPWebBrokerBridge.Create(nil);
try
lServer.DefaultPort := APort;
lServer.MaxConnections := dotEnv.Env('dmvc.webbroker.max_connections', 0);
lServer.ListenQueue := dotEnv.Env('dmvc.indy.listen_queue', 500);
lServer.Active := True;
WriteLn('CTRL+C to shutdown the server');
WaitForTerminationSignal;
EnterInShutdownState;
2019-05-19 14:06:12 +02:00
finally
lServer.Free;
end;
end;
begin
ReportMemoryLeaksOnShutdown := True;
IsMultiThread := True;
try
if WebRequestHandler <> nil then
WebRequestHandler.WebModuleClass := WebModuleClass;
dotEnv(
NewDotEnv
.WithStrategy(TMVCDotEnvPriority.FileThenEnv)
//if available, by default, loads default environment (.env)
.UseProfile('test') //if available loads the test environment (.env.test)
.UseProfile('prod') //if available loads the prod environment (.env.prod)
.Build() //uses the executable folder to look for .env* files
);
WebRequestHandlerProc.MaxConnections := dotEnv.Env('dmvc.handler.max_connections', 1024);
RunServer(dotEnv.Env('dmvc.server.port', 9999));
2019-05-19 14:06:12 +02:00
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.