Skip to content

Commit

Permalink
crawler lane updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Hai Zheng committed Dec 7, 2023
1 parent 933287a commit 9c95db2
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/crawler.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,20 +281,24 @@ public static function start($force = false)
*/
private function _crawl_data($force)
{
self::debug('......crawler started......');
if ($force) {
// Log pid to prevent from multi running
if (!defined('LITESPEED_LANE_HASH')) {
define('LITESPEED_LANE_HASH', Str::rrand(8));
}
if (!$this->_check_valid_lane()) {
// Take over lane
$this->_take_over_lane();
}
if (!defined('LITESPEED_LANE_HASH')) {
define('LITESPEED_LANE_HASH', Str::rrand(8));
}
if ($this->_check_valid_lane()) {
// Take over lane
self::debug('Take over lane as lane is free');
$this->_take_over_lane();
} else {
if ($this->_check_valid_lane()) {
// Take over lane
$this->_take_over_lane();
if ($force) {
self::debug('......crawler started (forced)......');
// Log pid to prevent from multi running
if (defined('LITESPEED_CLI')) {
// Take over lane
self::debug('Forced take over lane (CLI)');
$this->_take_over_lane();
}
} else {
self::debug('......crawler started......');
}
}

Expand Down

0 comments on commit 9c95db2

Please sign in to comment.