From fbe17d0bc39cbfd2eaae365e98b25e702e0c65ee Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 22 Dec 2023 07:43:02 +0200 Subject: [PATCH] prevent multi-thread execution --- src/cli/bot.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/cli/bot.php b/src/cli/bot.php index 088c7f1..4e30f06 100644 --- a/src/cli/bot.php +++ b/src/cli/bot.php @@ -10,6 +10,21 @@ $config = json_decode( ) ); +// Prevent multi-thread execution +$semaphore = sem_get( + crc32( + __DIR__ . '.twister.rss.bot' + ), + 1 +); + +if (false === sem_acquire($semaphore, true)) +{ + exit( + _('Process locked by another thread') . PHP_EOL + ); +} + // Connect twister try {