public static function isRunning(string $pidFile = null): bool
    {
        $pidFile = $pidFile ?? self::getDefaultPidFile();

        if (! \file_exists($pidFile)) {
            return false;
        }

        $address  = \file_get_contents($pidFile);
        $pos      = \mb_strrpos($address, ':');
        $hostname = \mb_substr($address, 0, $pos);
        $port     = \mb_substr($address, $pos + 1);

        if (false !== $fp = @fsockopen($hostname, (int) $port, $errno, $errstr, 1)) {
            fclose($fp);

            return true;
        }

        \unlink($pidFile);

        return false;
    }
public static function isRunning(string $pidFile = null): bool
    {
        $pidFile = $pidFile ?? self::getDefaultPidFile();

        if (! \file_exists($pidFile)) {
            return false;
        }

        $address  = \file_get_contents($pidFile);
        $pos      = \mb_strrpos($address, ':');
        $hostname = \mb_substr($address, 0, $pos);
        $port     = \mb_substr($address, $pos + 1);

        if (false !== $fp = @fsockopen($hostname, (int) $port, $errno, $errstr, 1)) {
            fclose($fp);

            return true;
        }

        \unlink($pidFile);

        return false;
    }
public static function isRunning ( string $ pidFile = null ) : bool { $ pidFile = $ pidFile ?? self :: getDefaultPidFile ( ) ; if ( ! \ file_exists ( $ pidFile ) ) { return false ; } $ address = \ file_get_contents ( $ pidFile ) ; $ pos = \ mb_strrpos ( $ address , ':' ) ; $ hostname = \ mb_substr ( $ address , 0 , $ pos ) ; $ port = \ mb_substr ( $ address , $ pos + 1 ) ; if ( false !== $ fp = @ fsockopen ( $ hostname , ( int ) $ port , $ errno , $ errstr , 1 ) ) { fclose ( $ fp ) ; return true ; } \ unlink ( $ pidFile ) ; return false ; }
Check if a server is running.

@param null|string $pidFile

@return bool
Check if a server is running .