How To…Create a Windows Service

Question

“How can I run my report server as a Windows Service?”

Solution

RB Server Edition includes a windows service called ReportBuilder Services. ReportBuilder Services can host your report server. For details see RBServer\Windows Services\ReadMe.doc.

A second solution is to create a custom windows service. This is the approach we recommend when multiple report servers need to run on a single machine.

Download: CustomRBServiceApp.zip

Steps:

  1. Use Delphi to create a Windows Service Application project (File | New | Other | Service).
  2. Place a TrsServer component on the Service module. (Add a separate DataModule for each ReportVolume component).
  3. Use the Object Inspector to modify the TService properties such as Name and DisplayName.
  4. Use the Object Inspector to configure the TrsServer properties such as Port.
  5. To install the windows service run the application with a /INSTALL parameter (Use the Delphi Run | Parameters dialog).
  6. To uninstall the windows service run this application with the /UNINSTALL parameter.

Sample Delphi code:

{------------------------------------------------------------------------------}
{ TmyReportService1.StartReportServer }

function TmyReportService1.StartReportServer: Boolean;
begin
  rsServer1.Active := True;
  Result := rsServer1.Active;

end;

{------------------------------------------------------------------------------}
{ TmyReportService1.StopReportServer }

function TmyReportService1.StopReportServer: Boolean;
begin
  rsServer1.Active := False;
  Result := not(rsServer1.Active);

end;

{------------------------------------------------------------------------------}
{ TmyReportService1.ServiceStart }

procedure TmyReportService1.ServiceStart(Sender: TService; var Started: Boolean);
begin
  StartReportServer;
end;

{------------------------------------------------------------------------------}
{ TmyReportService1.ServiceStop }

procedure TmyReportService1.ServiceStop(Sender: TService; var Stopped: Boolean);
begin
  Stopped := StopReportServer;
end;

{------------------------------------------------------------------------------}
{ TmyReportService1.ServiceShutdown }

procedure TmyReportService1.ServiceShutdown(Sender: TService);
begin
  StopReportServer;

end;

{------------------------------------------------------------------------------}
{ TmyReportService1.ServiceContinue }

procedure TmyReportService1.ServiceContinue(Sender: TService; var Continued: Boolean);
begin
  StartReportServer;
end;

{------------------------------------------------------------------------------}
{ TmyReportService1.ServicePause }

procedure TmyReportService1.ServicePause(Sender: TService; var Paused: Boolean);
begin
  StopReportServer;
end;