#1 2021-04-17 09:38:54

radexpol
Member
From: Poland, Krk
Registered: 2019-11-29
Posts: 116

Service without GUI

How to implement the SOA Service without GUI/Console/Service?

program FishShopDaemon;

uses
   ....  
   mORMot;

begin
  fServer := TSQLRestServerFullMemory.CreateWithOwnModel([], False, FISHSHOP_ROOT);
  fServer.ServiceDefine(instance, [IFishShop], FISHSHOP_CONTRACT);
  fHttpServer := TSQLHttpServer.Create(FISHSHOP_PORT, fServer);

            ???????  -> repeat until application.processMessages?

  fServer.Free;
  fHttpServer.Free;

end.

Offline

#2 2021-04-17 11:40:03

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: Service without GUI

See TSynDaemon class and usage samples in SQLite3/Samples/37 - FishShop Service (or 35 - practical DDD)

Offline

#3 2021-04-17 13:12:30

macfly
Member
From: Brasil
Registered: 2016-08-20
Posts: 374

Re: Service without GUI

You can use a daemon as mentioned by mpv to run in the background.

If you want the console window to be visible, use a WriteLn()...


begin
  ...
  fHttpServer := TSQLHttpServer.Create(FISHSHOP_PORT, fServer);
  try
    writeln('Server running. Press any key to stop...');
  finaly
    fHttpServer.Free;
    ....
  end;
end.

Offline

#4 2021-04-17 16:47:25

Vitaly
Member
From: UAE
Registered: 2017-01-31
Posts: 168
Website

Re: Service without GUI

Service (TSynDaemon) executable can be also launched in console mode with the /console parameter, like

YourService.exe /console

It might be useful, for example, for service debugging from Delphi with the corresponding property in project options:

<Debugger_RunParams>/console</Debugger_RunParams>

Offline

#5 2021-04-17 19:24:30

radexpol
Member
From: Poland, Krk
Registered: 2019-11-29
Posts: 116

Re: Service without GUI

Sorry, my mistake. I would like to create invisible client instance (>100 instances).

So, does the deamon helps me or use the while true Application.ProcessMessages;

program FishShopDaemon;

uses
   ....  
   mORMot;

begin
  connector := TSQLHttpClientWebsockets.Create('127.0.0.1', '1414', TSQLModel.Create([]), False, '', '', 30000, 30000, 30000);
  connector.WebSocketsUpgrade(myPassword);
  if not connector.ServerTimeStampSynchronize then
    raise EServiceException.Create('Error connecting to the server');
  connector.ServiceDefine([IService],sicShared);

  if not connector.Services.Resolve(IService,Service) then
    raise EServiceException.Create('Service unavailable');

   ???????  -> repeat until application.processMessages?

  connector.Free;

end.

Offline

#6 2021-04-18 17:11:14

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: Service without GUI

See the multi-thread tests in TestSQL3.dpr for some code with concurrent clients.

Offline

Board footer

Powered by FluxBB