Check for low power (Was: Re: 4D Server as a Service on OSX)

Bernd Fr?hlich (6/4/14 8:51AM)

Bernd Fr?hlich (6/4/14 8:51 AM)

Mitchell Shiller wrote:

color><param>00000,0000,DDEE/param>TThe scenario is as follows.
The server is installed in a region where power failures occur at an
all too frequent occurrence.
There is a UPS connected to the system but this provides at best 1
hour of additional run time.
When the UPS is running down is forces a shut down of the server.
So the call to shutdown is external to 4D.

Unless there is a way to detect the Shutdown "message" from the OS,
than calling it internally does not help.
I have solved that problem as follows:
Start a process on the Server that calls the "BatteryCheck" Method
every few Seconds/Minutes.
If the battery is below 25% call QUIT 4D.
Additionally I display a warning message on the server if it is
running on battery, so the user can take action in case somebody is

?// Methode: Batterycheck
?// Angelegt: BF 09.05.06
?// Objekt: Dienstroutine
?// Beschreibung: Pr¸ft, ob der Rechner auf Batteriestrom l?uft
?// und gibt den F¸llstand in % zur¸ck, falls das der Fall ist
?// ----------------------------------------------------



LAUNCH EXTERNAL PROCESS("pmset -g ps";$tIn;$tOut)
If (OK=1)
If ($lPos>3) ?//Rechner hat Batterie (Eingebaut oder USV)
If (Position("AC Power";$tOut)>0) ?//Rechner hat Strom, Batterie wird
End if
Else ?=A0//Rechner hat keine Batterie (l?uft am Netz)
End if
bLogWrite ("Fehler beim Batteriecheck!";10)
End if

Greetings from Germany,
Bernd Fr^hlich

Reply to this message

Summary created 6/4/14 at 12:44PM by Intellex Corporation

Comments welcome at: