DELPHI development LINUX random start service

DELPHI development LINUX random start service

Under Linux has a similar windows service functions.

Linux Daemon is one of a kind way, command line operation

Direct return, while establishing a similar process in the background. Interview clients. Some common services are basically linux

Such work. Such as the famous apache, mysql and so on.

program Project2;

{$APPTYPE CONSOLE}

{$R *.res}
uses
  Posix.Unistd,
  Posix.SysTypes,
  System.SysUtils,
  dmp in 'dmp.pas' {dmf: TDataModule};

procedure daemon;

begin

   dmf:=Tdmf.Create(nil);
   dmf.IdHTTPServer1.Active:=True;

  try

    repeat

      sleep(10 * 1000);

    until False;

  finally
   dmf.Free;
  end;

end;

var
   pid: pid_t;

begin
  pid := fork;
  if pid = 0 then
   begin
    writeln('starting service');
     daemon;
   end;

end.

  

Guess you like

Origin www.cnblogs.com/hnxxcxg/p/11458640.html