Created
May 11, 2015 16:51
-
-
Save SemanticallyNull/9571bacadf2da7f47f5e to your computer and use it in GitHub Desktop.
Beanstalk CLI queue monitor in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "queuemon", | |
"description": "Beanstalk CLI queue monitor", | |
"require": { | |
"pda/pheanstalk": "^3.0" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require(__DIR__ . "/vendor/autoload.php"); | |
use Pheanstalk\Pheanstalk; | |
$pheanstalk = new Pheanstalk('127.0.0.1'); | |
$mask = "|%-15.15s |%-10.10s |%-10.10s |%-10.10s |\n"; | |
printf($mask, 'queue', 'ready', 'reserved', 'workers'); | |
while(true) { | |
$tubes = $pheanstalk->listTubes(); | |
foreach($tubes as $tube) { | |
$ts = $pheanstalk->statsTube($tube); | |
printf($mask, $tube, $ts['current-jobs-ready'], $ts['current-jobs-reserved'], $ts['current-watching']); | |
} | |
sleep(1); | |
echo "\033[".count($tubes)."A"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment