summaryrefslogtreecommitdiff
path: root/tools/worker.php
blob: d0623eb41de7e5f1c4a8b8ec94c323123258645c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/php
<?php
/* worker.php - part of advanced build vichan feature */

require __DIR__ . '/inc/cli.php';
require_once 'inc/controller.php';

$config['smart_build'] = false; // Let's disable it, so we can build the page for real
$config['generation_strategies'] = ['strategy_immediate'];

function after_open_board() { global $config;
  $config['smart_build'] = false;
  $config['generation_strategies'] = ['strategy_immediate'];
};

echo "Hello world!\n";

$queue = get_queue('generate');

while (true) {
  $q = $queue->pop(2);
  foreach ($q as $v) {
    [$__, $func, $ary, $action] = unserialize($v);
    echo "Starting to generate $func ".implode(" ", $ary)."... ";

    call_user_func_array($func, $ary);

    echo "done!\n";
  }
  if (!$q) usleep(20000); // 0.02s
}