forked from owner888/phpspider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.php
41 lines (31 loc) · 847 Bytes
/
demo.php
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
32
33
34
35
36
37
38
39
40
41
<?php
ini_set("memory_limit", "1024M");
include "core/worker.php";
if (util::lock('phpspider'))
{
$errmsg = "phpspider process has been locked";
echo $errmsg."\n";
log::add($errmsg, "Warning");
exit(0);
}
$count = 8;
$w = new worker();
$w->count = $count;
$w->run_once = true;
$w->log_show = false;
$w->on_start = function($worker) {
};
$w->on_worker_start = function($worker) {
};
$w->on_worker_stop = function($worker) {
$time = microtime(true) - $worker->time_start;
$memory = util::memory_get_peak_usage();
echo "Worker[{$worker->worker_id}] Done in $time seconds\t $memory\n";
};
$w->on_stop = function($worker) {
util::unlock('phpspider');
$time = microtime(true) - $worker->time_start;
$memory = util::memory_get_peak_usage();
echo "Done in $time seconds\t $memory\n";
};
$w->run();