mirror of
https://github.com/YGGverse/Yo.git
synced 2025-03-12 13:21:29 +00:00
stop crawler on network connection lost #11
This commit is contained in:
parent
b475b4e61b
commit
d44bf90fe3
@ -19,6 +19,7 @@
|
||||
"symfony/dom-crawler": "^6.3",
|
||||
"jdenticon/jdenticon": "^1.0",
|
||||
"yggverse/ftp": "^1.0",
|
||||
"gregwar/captcha": "^1.2"
|
||||
"gregwar/captcha": "^1.2",
|
||||
"yggverse/net": "^1.2"
|
||||
}
|
||||
}
|
||||
|
@ -350,5 +350,17 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"network":
|
||||
{
|
||||
"check":
|
||||
{
|
||||
"enabled":true,
|
||||
"timeout":5,
|
||||
"socket":
|
||||
{
|
||||
"201:5eb5:f061:678e:7565:6338:c02c:5251":80
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -65,6 +65,65 @@ if (false === sem_acquire($semaphore, true))
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check network connection
|
||||
if ($config->network->check->enabled)
|
||||
{
|
||||
$network = false;
|
||||
|
||||
foreach ($config->network->check->socket as $host => $port)
|
||||
{
|
||||
if ($config->cli->document->crawl->debug->level->notice)
|
||||
{
|
||||
echo sprintf(
|
||||
_('[%s] [notice] check network connection to socket "%s" port "%d"...') . PHP_EOL,
|
||||
date('c'),
|
||||
$host,
|
||||
$port
|
||||
);
|
||||
}
|
||||
|
||||
if (\Yggverse\Net\Socket::isOpen($host, $port, $config->network->check->timeout))
|
||||
{
|
||||
if ($config->cli->document->crawl->debug->level->notice)
|
||||
{
|
||||
echo sprintf(
|
||||
_('[%s] [notice] network connection test successful') . PHP_EOL,
|
||||
date('c')
|
||||
);
|
||||
}
|
||||
|
||||
$network = true;
|
||||
break;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if ($config->cli->document->crawl->debug->level->warning)
|
||||
{
|
||||
echo sprintf(
|
||||
_('[%s] [warning] could not connect to socket "%s" port "%d"...') . PHP_EOL,
|
||||
date('c'),
|
||||
$host,
|
||||
$port
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$network)
|
||||
{
|
||||
if ($config->cli->document->crawl->debug->level->error)
|
||||
{
|
||||
echo sprintf(
|
||||
_('[%s] [error] network unreachable!') . PHP_EOL,
|
||||
date('c')
|
||||
);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Init client
|
||||
try {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user