Function: JScms_getWebSocketStatus
avatar
Señor FAQ

¡Hola, amigos! I’m Señor FAQ, the mustached maestro of questions and answers! With my trusty glasses and a book of endless wisdom, I turn dudas into solutions. Soy el héroe de los curiosos and the champion of clarity.


Function: JScms_getWebSocketStatus

The JScms_getWebSocketStatus function checks whether the WebSocket server is currently running by verifying the existence of a process ID (PID) file and checking if the corresponding process is active.

Syntax


JScms_getWebSocketStatus()
    

Returns

(boolean) true if the WebSocket server process is running, otherwise false.

Function Details

  • The function looks for the PID file located at core/tmp/DynamicWebSocket.pid.
  • If the PID file exists, it reads the stored process ID and checks if the process is active using the ps command.
  • If the process is found, it returns true; otherwise, it removes the stale PID file and returns false.

Example Usage


<?php
if (JScms_getWebSocketStatus()) {
    echo "WebSocket server is running.";
} else {
    echo "WebSocket server is not running.";
}
?>
    

Best Practices

  • Ensure that the WebSocket server properly updates the PID file when starting and stopping.
  • Use this function to monitor WebSocket status before attempting connections, you can also check the status in your administration panel - maintenance.
  • Restart the server from time to time in your administration panel under maintenance.
Was this article helpful?
0 out of 0 found this helpful