mirror of
https://github.com/YGGverse/YGGo.git
synced 2025-02-03 10:25:52 +00:00
fix semaphores
This commit is contained in:
parent
48e0482dbd
commit
43776b5ff4
20
cli/yggo.php
20
cli/yggo.php
@ -16,16 +16,6 @@ if (php_sapi_name() != 'cli') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Lock multi-thread execution
|
||||
$semaphore = sem_get(crc32('crontab.crawler'), 1);
|
||||
|
||||
if (false === sem_acquire($semaphore, true)) {
|
||||
|
||||
CLI::danger(_('process locked by another thread.'));
|
||||
CLI::break();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Stop CLI execution on cleaner process running
|
||||
$semaphore = sem_get(crc32('crontab.cleaner'), 1);
|
||||
|
||||
@ -46,6 +36,16 @@ if (false === sem_acquire($semaphore, true)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Lock multi-thread execution
|
||||
$semaphore = sem_get(crc32('cli.yggo'), 1);
|
||||
|
||||
if (false === sem_acquire($semaphore, true)) {
|
||||
|
||||
CLI::danger(_('process locked by another thread.'));
|
||||
CLI::break();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Connect database
|
||||
$db = new MySQL(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
|
||||
|
||||
|
@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
// Stop cleaner on cli running
|
||||
$semaphore = sem_get(crc32('cli.yggo'), 1);
|
||||
|
||||
if (false === sem_acquire($semaphore, true)) {
|
||||
|
||||
echo 'cli.yggo process running in another thread.' . PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
|
||||
// Lock multi-thread execution
|
||||
$semaphore = sem_get(crc32('crontab.cleaner'), 1);
|
||||
|
||||
@ -9,14 +18,6 @@ if (false === sem_acquire($semaphore, true)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Stop cleaner on cli running
|
||||
$semaphore = sem_get(crc32('cli.yggo'), 1);
|
||||
|
||||
if (false === sem_acquire($semaphore, true)) {
|
||||
|
||||
echo 'cli.yggo process running in another thread.' . PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
|
||||
// Load system dependencies
|
||||
require_once(__DIR__ . '/../config/app.php');
|
||||
|
@ -1,14 +1,5 @@
|
||||
<?php
|
||||
|
||||
// Lock multi-thread execution
|
||||
$semaphore = sem_get(crc32('crontab.crawler'), 1);
|
||||
|
||||
if (false === sem_acquire($semaphore, true)) {
|
||||
|
||||
echo 'process locked by another thread.' . PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
|
||||
// Stop crawler on cli running
|
||||
$semaphore = sem_get(crc32('cli.yggo'), 1);
|
||||
|
||||
@ -18,6 +9,15 @@ if (false === sem_acquire($semaphore, true)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Lock multi-thread execution
|
||||
$semaphore = sem_get(crc32('crontab.crawler'), 1);
|
||||
|
||||
if (false === sem_acquire($semaphore, true)) {
|
||||
|
||||
echo 'process locked by another thread.' . PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
|
||||
// Load system dependencies
|
||||
require_once(__DIR__ . '/../config/app.php');
|
||||
require_once(__DIR__ . '/../library/ftp.php');
|
||||
|
Loading…
x
Reference in New Issue
Block a user