You are not logged in.
Pages: 1
Hi,
I have one server (http api) and n clients.
My server is based on TSQLHttpServer, my client is based on TSQLHttpClient and some services that are consumed by clients.
Sometimes I need to stop de server, but I cannot just kill the server, 'cause maybe some important process are runing.
To stop the server I implemented:
- delete all users to stop new connections;
- wait that all request finished;
- and finally, freeandnil on my server object.
Below my code:
procedure TMyServer.StopServer;
var
oSQLAuthUser: TSQLAuthUser;
begin
oSQLAuthUser := TSQLAuthUser.Create;
try
oSQLAuthUser.FillPrepare(oSQLRestServerFullMemory);
while (oSQLAuthUser.FillOne) do
oSQLRestServerFullMemory.Delete(TSQLAuthUser, oSQLAuthUser.ID); // delete all users. This way I stop new clients connections.
finally
oSQLAuthUser.Free;
end;
while fDBServers[0].Server.Stats.ClientsCurrent > 0 do // until have clients, just wait...
sleep(1000);
end;
And ...
procedure TMyServerAPP.StopServer;
begin
fMyServer.StopServer;
FreeAndNil(fMyServer);
end;
It's work... but I imagine that's not the best way to do this... Someone have any suggestion?
Thanks by your attention,
Dorival
Last edited by dorival (2014-06-25 20:30:23)
Offline
of course, it's done.
Thanks
Offline
It has just been implemented as TSQLRestServer.Shutdown and TSQLHttpServer.Shutdown methods.
See http://synopse.info/fossil/info/4d4d2be … 8b328ae483
Offline
Thank you AB.
Offline
A small note:
More correctly "shutting down", with two letters t.
Offline
Pages: 1