Once you have set all required configurations of your server, there are 2 useful events to know when server has started and when has stopped.
This event is fired when server has started and can process new connections.
procedure OnStartup(Sender: TObject);
begin
WriteLn('#server started');
end;
This event is fired after server has stopped and no more connections are accepted.
procedure OnShutdown(Sender: TObject);
begin
WriteLn('#server stopped');
end;