Jump to content

Recommended Posts

Posted

Hello,

I've build my service :

program Project1;
uses
  SvcMgr,
  ServerModule in 'ServerModule.pas' {UniServerModule: TUniGUIServerModule},
  MainModule in 'MainModule.pas' {UniMainModule: TUniGUIMainModule},
  Main in 'Main.pas' {MainForm: TUniForm},
  ServiceModule in 'ServiceModule.pas' {UniServiceModule: TUniGUIService};

  ...other units here... 
{$R *.res} 
begin
  if not Application.DelayInitialize or Application.Installing then
    Application.Initialize;
  Application.CreateForm(TUniServiceModule, UniServiceModule);
  Application.Run;
end.

And in my ServiceModule I've placed :

procedure TUniServicePFAC.ServiceStart(Sender: TService;  var Started: Boolean);

begin
   TUniServerModule.Create(Application);
   Started := True;
end;

Is it the correct way ? 
I've notice that if I don't place : TUniServerModule.Create(Application); 
Even if the service is running, In the browser with http://192.XXX.XXX.XX:8077 can't connect to the application....

Big thank you in advance for your help.
With best regards,
Hervé

 

Posted

Hello,

Manually calling TUniServerModule.Create(Application) in ServiceStart is not the correct way to initialize a uniGUI service application.

uniGUI is designed to handle the server module lifecycle internally. When you use a proper TUniGUIService-based project structure, the server module is created automatically during Application.Initialize, as long as SetServerClass(UniGUIServerModuleClass) is called in InitService.

Creating it manually bypasses the framework's lifecycle management and can lead to instability or unexpected issues (e.g. session handling, port conflicts, etc.).

I recommend removing that line and ensuring your project follows the standard uniGUI Windows Service template.

  • Thanks 1
Posted

Hello,

Thank you for the explication.

Ok, I've removed it, but now I've got a message : 192.xxx.xxx.xx:8077 refuse to connect...

I don't see what's wrong...

with best regards,

Hervé.

Posted

Hello, 

where I could have a sample of a ServiceModule code that is working fine for an unigui application, please ?

Wiht best regards,

Hervé

Posted
5 minutes ago, Hervé said:

where I could have a sample of a ServiceModule code that is working fine for an unigui application, please ?

You can check by simply creating an empty project.

image.png.37402b03f2a048bf6cf6a2de98f14723.png

image.png.70c08dfa17f3a8c6d75ee450f356ac26.png

  • Thanks 1
Posted

Hello !

A big big thank you ! It works very well...

I've forget this wizard, since I've started my project ...And I was looking for something that was under my nose ! :)

20/20 for the support!

Have a nice evening,

Big thank you!

With best regards,

Hervé. 

  • Thanks 1
×
×
  • Create New...