Proyecto

General

Perfil

Descargar (2,4 KB) Estadísticas
| Rama: | Revisión:
program gsvadtosaula;

{$mode objfpc}{$H+}

uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, SysUtils, CustApp
{ you can add units after this }, globales;

type

{ gsvaulalinex }

gsvaulalinex = class(TCustomApplication)
protected
procedure DoRun; override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure WriteHelp; virtual;
end;

{ gsvaulalinex }

procedure gsvaulalinex.DoRun;
const
SERVERADTOSAULA_ESTADO:string='pgrep serveradtosaula';
CERRAR_PUERTO:string='fuser -k -n tcp 38001';
REINICIAR_SERVERADTOSAULA:string='/etc/init.d/serveradtosaula start';
var
ErrorMsg: String;
inserver:integer;
sserver:String;
begin
ErrorMsg:=CheckOptions('h','help');
if ErrorMsg<>'' then
begin
ShowException(Exception.Create(ErrorMsg));
Terminate;
Exit;
end;
if HasOption('h','help') then
begin
WriteHelp;
Terminate;
Exit;
end;
while( not terminated ) do
begin
try
inc(g_contador);
if (g_contador>400) then
begin
sserver:='';
sserver:=Trim(HallarDato(SERVERADTOSAULA_ESTADO));
if (sserver='') then
begin
Ejecutar(CERRAR_PUERTO);
Ejecutar(REINICIAR_SERVERADTOSAULA);
end;
g_contador:=0;
end;
sleep(50);
except
break;
end;
end;
Terminate;
end;

constructor gsvaulalinex.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
StopOnException:=True;
end;

destructor gsvaulalinex.Destroy;
begin
inherited Destroy;
end;

procedure gsvaulalinex.WriteHelp;
begin
writeln('Usage: ',ExeName,' -h');
end;
var
Application: gsvaulalinex;

{$IFDEF WINDOWS}{$R gsvaulalinex1.rc}{$ENDIF}

begin
Application:=gsvaulalinex.Create(nil);
Application.Title:='guarda_svadtosaula';
Application.Run;
Application.Free;
end.

(4-4/6)