PHP Classes

File: src/Terremoth/Async/background_processor.php

Recommend this page to a friend!
  Classes of Lucas Marques Dutra   PHP Async   src/Terremoth/Async/background_processor.php   Download  
File: src/Terremoth/Async/background_processor.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PHP Async
Run scripts in parallel using the PHP CLI command
Author: By
Last change:
Date: 17 days ago
Size: 966 bytes
 

Contents

Class file image Download
<?php

ini_set
('display_errors', 'on');
ini_set('display_startup_errors', 1);
ini_set('error_log', 'php-async-errors-' . date('YmdH') . '.log');
error_reporting(E_ALL);

require_once
'vendor/autoload.php';
require_once
__DIR__ . DIRECTORY_SEPARATOR . 'script_functions.php';

use
Laravel\SerializableClosure\SerializableClosure;

if (!isset(
$argv[1])) {
   
error('Shmop Key not provided');
    exit(
1);
}

$key = (int)$argv[1];

$shmopInstance = shmop_open($key, 'a', 0, 0);

if (!
$shmopInstance) {
   
error('Could not open Shmop');
    exit(
1);
}

$length = shmop_size($shmopInstance);

if (
$length === 0) {
   
error('Shmop length cannot be zero!');
    exit(
1);
}

$dataCompressed = shmop_read($shmopInstance, 0, $length);
$data = stringFromMemoryBlock($dataCompressed);

/**
 * @var SerializableClosure $serializedClosure
 * @var callable $closure
 */
$serializedClosure = unserialize($data);
$closure = $serializedClosure->getClosure();
$closure();

exit(
0);