1:前提

系统:CentOS

PHP版本:PHP7     安装目录:/usr/local/php

php-resque          安装目录:/home/software/php-resque

worker                存放目录:/usr/local/nginx/resque-worker

2:job   /home/software/php-resque/demo/queue.php

if(empty($argv[1])) {
die('Specify the name of a job to add. e.g, php queue.php PHP_Job');
} require __DIR__ . '/init.php';
date_default_timezone_set('PRC');
Resque::setBackend('localhost:6379'); // You can also use a DSN-style format:
//Resque::setBackend('redis://user:pass@127.0.0.1:6379');
//Resque::setBackend('redis://user:pass@a.host.name:3432/2'); $args = array(
'time' => time(),
'array' => array(
'test' => 'test',
),
); $jobId = Resque::enqueue('default', $argv[1], $args, true);
echo "Queued job ".$jobId."\n\n";

3:workers       目录:/usr/local/nginx/resque-worker

sendmail.php

<?php
class SendMail{   public function perform(){
    file_put_contents(__DIR__.'/sendmail.txt',date('Y-m-d H:i:s').PHP_EOL,FILE_APPEND);
  } }

4:添加常驻进程

#!/bin/bash

#
### BEGIN INIT INFO
# Provides: php-resque
# Default-Start:
# Default-Stop:
# Short-Description: Start and stop the php-resque service daemon
# Description: Controls the main php-resque service daemon "php-resque"
### END INIT INFO
# export APP_INCLUDE=/usr/local/nginx/resque-worker/require.php
export QUEUE=default
export COUNT=
export VVERBOSE= # for debugging
export REDIS_BACKEND=localhost:
#. /etc/rc.d/init.d/functions start() {
su -s /bin/bash www-data -c "/usr/local/php/bin/php /home/software/php-resque/bin/resque.php > /var/log/php-resque.log 2>&1" &
#su -s /bin/bash www-data -c "/usr/local/php/bin/php /home/software/php-resque/demo/resque.php > /var/log/php-resque.log 2>&1" &
} stop() {
ps -ef | grep resque | grep -v grep | grep -v resque-web | awk '{print $2}' | xargs kill -
}
kill() {
ps -ef | grep resque | grep -v grep | grep -v resque-web | awk '{print $2}' | xargs kill -
}
case "$1" in
start)
number=$(ps aux | grep php-resque/bin/resque.php | grep -v grep | wc -l)
if [ $number -gt ]
then
echo "php-resque is running. ($number workers)"
echo "You may wanna stop them before you start."
else
start
fi
;; stop)
stop
;; kill)
kill
;; status)
number=$(ps aux | grep php-resque/bin/resque.php | grep -v grep | wc -l)
if [ $number -gt ]
then
echo "php-resque is running. ($number workers)"
else
echo "php-resque is not running."
fi
;; *)
echo -n "Usage: $0 {start|stop|status}"
esac

5:移到php项目中

cp -R  /home/software/php-resque  /usr/local/nginx/www/protected/vendor/php-resque

6:在控制器里调用  vim /usr/local/nginx/www/protected/conterollers/ResqueController.php

/**
* Description of ResqueController
*
* @author dxh20012012001@sina.com
*/
class ResqueController extends Controller { //put your code here
public function actionIndex() {
Yii::import('application.vendor.php-resque.vendor.autoload', true);
$resque = new Resque();
$resque->setBackend('127.0.0.1:6381');
$job = $resque->enqueue('default', 'SendMail');
echo '<pre>';
print_r($job);
echo '</pre>';
die('FILE:' . __FILE__ . '; LINE:' . __LINE__);
} }

  

php-resque学习笔记二(配置)的更多相关文章

  1. Struts2学习笔记二 配置详解

    Struts2执行流程 1.简单执行流程,如下所示: 在浏览器输入请求地址,首先会被过滤器处理,然后查找主配置文件,然后根据地址栏中输入的/hello去每个package中查找为/hello的name ...

  2. Struts2学习笔记(二)——配置详解

    1.Struts2配置文件加载顺序: default.properties(默认常量配置) struts-default.xml(默认配置文件,主要配置bean和拦截器) struts-plugin. ...

  3. 转:C#制作ORM映射学习笔记二 配置类及Sql语句生成类

    在正式开始实现ORM之前还有一点准备工作需要完成,第一是实现一个配置类,这个很简单的就是通过静态变量来保存数据库的一些连接信息,等同于.net项目中的web.config的功能:第二需要设计实现一个s ...

  4. JMX学习笔记(二)-Notification

    Notification通知,也可理解为消息,有通知,必然有发送通知的广播,JMX这里采用了一种订阅的方式,类似于观察者模式,注册一个观察者到广播里,当有通知时,广播通过调用观察者,逐一通知. 这里写 ...

  5. InterSystems Ensemble学习笔记(二) Ensemble创建镜像, 实现自动故障转移

    系列目录 InterSystems Ensemble学习笔记(一) Ensemble介绍及安装InterSystems Ensemble学习笔记(二) Ensemble创建镜像, 实现自动故障转移 一 ...

  6. kvm虚拟化学习笔记(二)之linux kvm虚拟机安装

    KVM虚拟化学习笔记系列文章列表----------------------------------------kvm虚拟化学习笔记(一)之kvm虚拟化环境安装http://koumm.blog.51 ...

  7. amazeui学习笔记二(进阶开发5)--Web 组件开发规范Rules

    amazeui学习笔记二(进阶开发5)--Web 组件开发规范Rules 一.总结 1.见名知意:见那些class名字知意,见函数名知意,见文件名知意 例如(HISTORY.md Web 组件更新历史 ...

  8. JDBC学习笔记二

    JDBC学习笔记二 4.execute()方法执行SQL语句 execute几乎可以执行任何SQL语句,当execute执行过SQL语句之后会返回一个布尔类型的值,代表是否返回了ResultSet对象 ...

  9. ZooKeeper学习笔记二:API基本使用

    Grey ZooKeeper学习笔记二:API基本使用 准备工作 搭建一个zk集群,参考ZooKeeper学习笔记一:集群搭建. 确保项目可以访问集群的每个节点 新建一个基于jdk1.8的maven项 ...

  10. MongoDB学习笔记二- Mongoose

    MongoDB学习笔记二 Mongoose Mongoose 简介 之前我们都是通过shell来完成对数据库的各种操作, 在开发中大部分时候我们都需要通过程序来完成对数据库的操作 而Mongoose就 ...

随机推荐

  1. java反射生成ORM

    package com.wzh.jdbc; import java.lang.reflect.Field;import java.sql.Connection;import java.sql.Prep ...

  2. GCD信号量并发控制

    /** *  当我们在处理一系列线程的时候,当数量达到一定量,在以前我们可能会选择使用NSOperationQueue来处理并发控制,但如何在GCD中快速的控制并发呢?答案就是dispatch_sem ...

  3. Python标准库11 多进程探索 (multiprocessing包)

    作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 在初步了解Python多进程之后,我们可以继续探索multiprocessing包 ...

  4. Objective-C: 字符串NSString与NSMutableString

    字符串算是OC中非常重要和常用的一部分内容,OC中的字符串与我之前在学习C,C++,Java中的字符串有一定的不同,它非常类似于C++中容器的概念,但用法却与之还是有很大的不同,也许是因为OC的语法就 ...

  5. JDK环境变量中dt.jar、tools.jar等变量值的作用

    变量名:CLASSPATH 变量值:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar; tools.jar: 工具类 库,它跟我们程序中用到的 基础 ...

  6. Dubbo Multicast 注册中心即相关代码实现

    Dubbo 的 Multicast注册中心有下面特点: 不需要启动任何中心节点,只要广播地址一样,就可以互相发现 组播受网络结构限制,只适合小规模应用或开发阶段使用. 组播地址段: 224.0.0.0 ...

  7. ecmall程序结构图与常用数据库表

    ecm_acategory:存放的是商城的文章分类.ecm_address:存放的是店长的地址ecm_article:存放的是商城的相关文章ecm_brand:存放的是商城的品牌分类(注意与表ecm_ ...

  8. Hive分布式的数据仓库

    1.hive介绍 hive是一个数据仓库的解决方案,它的数据存储依赖于HDFS,数据结算依赖于MR,也就是说,hive就是一个在数据仓库的服务,它只需要安装到一台普通的PC上即可,仅仅对外提供SQL服 ...

  9. Library Cache: Lock, Pin and Load Lock

    What is "Library cache lock" ? This event controls the concurrency between clients of the ...

  10. mfc 数据库显示到editcontrol控件问题

    http://bbs.csdn.net/topics/390601634 CString CMyDB::VariantToString(const _variant_t &var) {     ...