Created
August 23, 2018 06:28
-
-
Save ammarfaizi2/364cf754de930d2352fc5f4ad36e9d53 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
require __DIR__."/../config/main.php"; | |
function reg(&$a, Closure $c) { | |
$a[] = $c; | |
} | |
$whileTrue = true; | |
$param = [ | |
"suara", | |
"liputan6", | |
"tribunnews", | |
"detik", | |
"kompas", | |
"antaranews", | |
"viva", | |
// "kabardaerah"// skipped due to cloudflare captcha | |
]; | |
$noend = ""; | |
if ($whileTrue) { | |
$noend = "--while-true"; | |
} | |
$a = []; | |
foreach ($param as $key => $value) { | |
reg($a, function() use ($value, $noend) { | |
cli_set_process_title("icetea_worker --module=icetea_scraper.so --target=$value"); | |
shell_exec( | |
"nohup ".PHP_BINARY." ".__DIR__."/scraper.php {$value} {$noend} >> ".LOG_DIR."/{$value}.log 2>&1" | |
); | |
}); | |
} | |
foreach ($a as $v) { | |
if (!isset($pid) || $pid !== 0) { | |
$pid = pcntl_fork(); | |
} | |
if (!$pid) { | |
while(true) { | |
$v(); | |
} | |
} | |
} | |
while (true) { | |
sleep(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment