• Privacy policy per contatti
  • Privacy policy per membri
  • Privacy policy per clienti e fornitori
  • Privacy by design guidelines
  • Cookie policy
  • Privacy policy per contatti
  • Privacy policy per membri
  • Privacy policy per clienti e fornitori
  • Privacy by design guidelines
  • Cookie policy
  • With Delphi you can create a Linux stand alone webBrocker application server as you can see in the following video:

    Yuo can also specify for you WebBrocker app the threadpool managing, that can help you to increase performance of your app server.

    In this example we configure a thread pool of 50 preallocated thread to manage connection shortly.

    To use thread pool you need to add “IdSchedulerOfThreadPool” unit in you code and you can associate “TIdSchedulerOfThreadPool” on server start:

    LServer: TIdHTTPWebBrokerBridge; LidScheduler: TIdSchedulerOfThreadPool; LResponse: string; LGetSSLPassword: TGetSSLPassword; LIOHandleSSL: TIdServerIOHandlerSSLOpenSSL; begin WriteCommands; LServer := TIdHTTPWebBrokerBridge.Create(nil); if Application = nil then WriteLn('Application is null'); WriteLn('Srv Connections:' + LServer.MaxConnections.ToString);// + ' App Connections:' + Application.MaxConnections.ToString); LServer.DefaultPort := APort; if (DmShared.Settings.certificate_file_name.Replace('-','').Trim <> '') then Begin if LServer.IOHandler <> nil then begin try LServer.IOHandler.Free; except end; LServer.IOHandler := nil; LGetSSLPassword := TGetSSLPassword.Create; LIOHandleSSL := TIdServerIOHandlerSSLOpenSSL.Create(LServer); LIOHandleSSL.SSLOptions.CertFile := DmShared.Settings.certificate_file_name; LIOHandleSSL.SSLOptions.RootCertFile := DmShared.Settings.certificate_root_file_name; LIOHandleSSL.SSLOptions.KeyFile := DmShared.Settings.certificate_key_file_name; LIOHandleSSL.SSLOptions.SSLVersions := [sslvTLSv1,sslvTLSv1_1,sslvTLSv1_2]; LIOHandleSSL.OnGetPassword := LGetSSLPassword.OnGetSSLPassword; LServer.IOHandler := LIOHandleSSL; LServer.OnQuerySSLPort := DmShared.onQuerySSLPort; // IVAN : 2022 05 29: INSERISCO LA GESTIONE DEI THREAD POOL - BOH VEDIAMO LidScheduler := TIdSchedulerOfThreadPool.Create; LidScheduler.MaxThreads := 0; LidScheduler.PoolSize := 100; LServer.Scheduler := LidScheduler; LServer.MaxConnections := 4096; StartServer(LServer); while True do begin Readln(LResponse); LResponse := LowerCase(LResponse); if LResponse.StartsWith(cCommandSetPort) then SetPort(LServer, LResponse) else if sametext(LResponse, cCommandStart) then StartServer(LServer) else if sametext(LResponse, cCommandStatus) then WriteStatus(LServer) else if sametext(LResponse, 'h') then begin show_headers := not show_headers; if show_headers then writeln('SHOW HEADERS: On') writeln('SHOW HEADERS: Off'); else if sametext(LResponse, 'd') then begin debug_mode := not debug_mode; if debug_mode then writeln('DEBUG: On') writeln('DEBUG: Off'); else if sametext(LResponse, cCommandStop) then StopServer(LServer) else if sametext(LResponse, cCommandHelp) then WriteCommands else if sametext(LResponse, cCommandExit) then if LServer.Active then begin StopServer(LServer); thLog.Terminate; thLog.WaitFor; FreeAndNil(thLog); break break begin Writeln(sInvalidCommand); Write(cArrow); finally LServer.Free;
    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
    procedure RunServer ( APort : Integer ) ;
    var
    LServer : TIdHTTPWebBrokerBridge ;
    LidScheduler : TIdSchedulerOfThreadPool ;
    LResponse : string ;
    LGetSSLPassword : TGetSSLPassword ;
    LIOHandleSSL : TIdServerIOHandlerSSLOpenSSL ;
    begin
    WriteCommands ;
    LServer : = TIdHTTPWebBrokerBridge . Create ( nil ) ;
    if Application = nil then
    WriteLn ( 'Application is null' ) ;
    WriteLn ( 'Srv Connections:' + LServer . MaxConnections . ToString ) ; // + ' App Connections:' + Application.MaxConnections.ToString);
    try
    LServer . DefaultPort : = APort ;
    if ( DmShared . Settings . certificate_file_name . Replace ( '-' , '' ) . Trim < > '' ) then
    Begin
    if LServer . IOHandler < > nil then
    begin
    try LServer . IOHandler . Free ; except end ;
    LServer . IOHandler : = nil ;
    end ;
    LGetSSLPassword : = TGetSSLPassword . Create ;
    LIOHandleSSL : = TIdServerIOHandlerSSLOpenSSL . Create ( LServer ) ;
    LIOHandleSSL . SSLOptions . CertFile : = DmShared . Settings . certificate_file_name ;
    LIOHandleSSL . SSLOptions . RootCertFile : = DmShared . Settings . certificate_root_file_name ;
    LIOHandleSSL . SSLOptions . KeyFile : = DmShared . Settings . certificate_key_file_name ;
    LIOHandleSSL . SSLOptions . SSLVersions : = [ sslvTLSv1 , sslvTLSv1_1 , sslvTLSv1_2 ] ;
    LIOHandleSSL . OnGetPassword : = LGetSSLPassword . OnGetSSLPassword ;
    LServer . IOHandler : = LIOHandleSSL ;
    LServer . OnQuerySSLPort : = DmShared . onQuerySSLPort ;
    // IVAN : 2022 05 29: INSERISCO LA GESTIONE DEI THREAD POOL - BOH VEDIAMO
    LidScheduler : = TIdSchedulerOfThreadPool . Create ;
    LidScheduler . MaxThreads : = 0 ;
    LidScheduler . PoolSize : = 100 ;
    LServer . Scheduler : = LidScheduler ;
    LServer . MaxConnections : = 4096 ;
    End ;
    StartServer ( LServer ) ;
    while True do
    begin
    Readln ( LResponse ) ;
    LResponse : = LowerCase ( LResponse ) ;
    if LResponse . StartsWith ( cCommandSetPort ) then
    SetPort ( LServer , LResponse )
    else if sametext ( LResponse , cCommandStart ) then
    StartServer ( LServer )
    else if sametext ( LResponse , cCommandStatus ) then
    WriteStatus ( LServer )
    else if sametext ( LResponse , 'h' ) then
    begin
    show_headers : = not show_headers ;
    if show_headers then
    writeln ( 'SHOW HEADERS: On' )
    Else
    writeln ( 'SHOW HEADERS: Off' ) ;
    end
    else if sametext ( LResponse , 'd' ) then
    begin
    debug_mode : = not debug_mode ;
    if debug_mode then
    writeln ( 'DEBUG: On' )
    Else
    writeln ( 'DEBUG: Off' ) ;
    end
    else if sametext ( LResponse , cCommandStop ) then
    StopServer ( LServer )
    else if sametext ( LResponse , cCommandHelp ) then
    WriteCommands
    else if sametext ( LResponse , cCommandExit ) then
    if LServer . Active then
    begin
    StopServer ( LServer ) ;
    thLog . Terminate ;
    thLog . WaitFor ;
    FreeAndNil ( thLog ) ;
    break
    end
    else
    break
    else
    begin
    Writeln ( sInvalidCommand ) ;
    Write ( cArrow ) ;
    end ;
    end ;
    finally
    LServer . Free ;
    end ;
    end ;