Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IW Service stops
#3
(04-18-2023, 10:50 AM)Comograma Wrote: I have an IW service running on Windows Server and after a while the service stops responding.
It is a big project with many users connected and after some work, with heavy load processing, when a user starts a session, the main page is not shown.
Tried everything without success.
After this starts to happen, the service is still running, no event logs on Windows service side, but main page is not loaded. No service logs entry either.
Any ideas?? This is urgent!!
Thanks


Have you considered using a profiler to help pinpoint the issue? I find that tools like the Sampling Profiler and Intel VTune Profiler (you'll need THIS for VTune) can be particularly helpful in these situations. Additionally, running FastMM4 in full debug mode can help you identify any memory leaks. At atozed, they have a helpful guide for this.

While you're working on identifying the root cause, you may also want to consider using content handlers to automatically detect when the service stops working and restart it.
In your ServerController.pas do add something like this:


Code:
uses
  IW.Content.Handlers,
  IW.Content.Health;

initialization

with THandlers.Add('', 'health-check', TContentHealth.Create) do
begin
  CanStartSession := true;
  RequiresSessionStart := false;
end;

and then make a new unit, like this to define your content handler:


Code:
unit IW.Content.Health;

interface

uses
  Classes, IW.Content.Base, HTTPApp, IWApplication, IW.HTTP.Request,
  IW.HTTP.Reply;

type
  TContentHealth = class(TContentBase)
  protected
    function Execute(aRequest: THttpRequest; aReply: THttpReply; const aPathname: string; aSession: TIWApplication; aParams: TStrings): boolean; override;
  public
    constructor Create; override;
  end;

implementation

uses
  IW.Content.Handlers,
  IWMimeTypes;

constructor TContentHealth.Create;
begin
  inherited;
  mFileMustExist := False;
end;

function TContentHealth.Execute(aRequest: THttpRequest; aReply: THttpReply; const aPathname: string; aSession: TIWApplication; aParams: TStrings): boolean;
begin
  Result := True;
  if Assigned(aReply) then
  begin
    aReply.ContentType := MIME_TXT;
    aReply.WriteString('ALLOK');
  end;
  aSession.Terminate;
end;

end.

Then, create a watchdog service that periodically sends a request to http://your_url/health-check and checks if the response is 'ALLOK'. If the response indicates that the server is running properly, the watchdog service does nothing. However, if the response is anything other than 'ALLOK', the watchdog service can take action to automatically restart the server.
Reply


Messages In This Thread
IW Service stops - by Comograma - 04-18-2023, 10:50 AM
RE: IW Service stops - by svenheuer - 04-18-2023, 12:41 PM
RE: IW Service stops - by ioan - 04-18-2023, 06:16 PM
RE: IW Service stops - by Comograma - 04-19-2023, 04:16 PM
RE: IW Service stops - by Alexandre Machado - 04-18-2023, 08:17 PM
RE: IW Service stops - by Alexandre Machado - 04-19-2023, 08:09 PM
RE: IW Service stops - by Comograma - 04-20-2023, 10:15 AM
RE: IW Service stops - by Alexandre Machado - 04-20-2023, 08:37 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)