Don't allow rebuild while a rebuild is in progress
authorCameron Ball <cameron@moodle.com>
Tue, 7 May 2019 02:34:32 +0000 (10:34 +0800)
committerCameron Ball <cameron@moodle.com>
Tue, 7 May 2019 02:34:32 +0000 (10:34 +0800)
src/gnb.php

index 6ec42c6..4d38a48 100644 (file)
@@ -75,12 +75,22 @@ getTelegram()->addCommand(
         protected $description = 'Generate the songs hash';
 
         public function handle($arguments) {
+            if (file_exists('/tmp/gnb.lock')) {
+                $this->replyWithMessage(
+                    [
+                        'text' => "Rebuild currently in progress, try again after it is complete."
+                    ]
+                );
+
+                return;
+            }
             $this->replyWithMessage(
                 [
                     'text' => "Building songs hash list... This will take a while."
                 ]
             );
             $chatid = getTelegram()->getWebhookUpdates()->get('message')->get('chat')->get('id');
+
             exec('/opt/hashgen.sh notify ' . $chatid . ' > /dev/null &');
         }
     }