Browsed by
Snippet Category: php

resque class

resque class

<?php class sendEmail { function perform() { include_once("/var/www/html/classes/class.mailer.php"); $oMailer = new mailer(); $email = $this->args["email"]; return $oMailer->sendMail("This is a test message sent from our queue", "test mail from queue", $email); } }

resque autoloader

resque autoloader

<?php include(dirname(__FILE__)."/sendEmail.php");

Install Redis

Install Redis

wget http://download.redis.io/redis-stable.tar.gz tar xzf redis-stable.tar.gz cd redis-stable make make test sudo make install

email job sent

email job sent

** [06:28:32 2018-04-30] Checking user:email ** [06:28:32 2018-04-30] Sleeping for 5 ** [06:28:37 2018-04-30] Checking user:email ** [06:28:37 2018-04-30] Found job on user:email ** [06:28:37 2018-04-30] got (Job{user:email} | ID: 0fa9351fc0bcd10a12396eaa75644021 | sendEmail | [{"email":"example@softsmart.co.za"}]) ** [06:28:37 2018-04-30] Forked 2573 at 2018-04-30 06:28:37 ** [06:28:37 2018-04-30] Processing user:email since 2018-04-30 06:28:37 ** [06:28:41 2018-04-30] done (Job{user:email} | ID: 0fa9351fc0bcd10a12396eaa75644021 | sendEmail | [{"email":"example@softsmart.co.za"}]) ** [06:28:41 2018-04-30] Checking user:email ** [06:28:41 2018-04-30] Sleeping for 5

PHP Resque worker threads

PHP Resque worker threads

*** Starting worker ubuntu:1970:* ** [05:19:13 2018-04-30] Checking user:email ** [05:19:13 2018-04-30] Sleeping for 5 ** [05:19:18 2018-04-30] Checking user:email ** [05:19:18 2018-04-30] Sleeping for 5 ** [05:19:23 2018-04-30] Checking user:email

resque

resque

cd /var/www/html/vendor/chrisboulton/php-resque/ sudo VVERBOSE=1 QUEUE=* COUNT=1 APP_INCLUDE="../../../queues/index.php" -u www-data php resque.php

email-queue

email-queue

include(dirname(__FILE__)."/php-resque/lib/Resque.php"); $start = microtime(true); $args = array("email" => $_POST["email"]; $id = Resque::enqueue("user:email", "sendEmail", $args); if( $id === false ) { print "adding to the queue failed<p>"; } else { print "Job ID: ".$id."<p>"; } $end = microtime(true); print "<p>Time elapsed in seconds: ".($end – $start);

no-queue-emailer

no-queue-emailer

include(dirname(__FILE__)."/classes/class.mailer.php"); $oMailer = new mailer(); $start = microtime(true); $x = $oMailer->sendMail("This is a test message", "test mail", $_POST["email"]); if( $x === true ) { print "Mail sending passed"; } else { print "Mail sending failed"; } $end = microtime(true); print "<p>Time elapsed in seconds: ".($end – $start);

GitClonePHPResque

GitClonePHPResque

git clone git://github.com/chrisboulton/php-resque.git