Elvuel

善战者无赫赫之功

  • Home
  • Atom
  • About Elvuel

rails中使用resque

庚寅[虎]年 十月廿七

1.安装
sudo apt-get install redis-server
gem install resque
gem install redis

2.配置
redis配置
vim /etc/redis/redis.conf (根据自身需要进行相应修改)

vim APP/config/initializers/load_redis.rb
require 'redis'
$redis = Redis.new :host =〉 '127.0.0.1' # default port : 6379

vim APP/config/initializers/load_resque.rb
首先: require 'resque'

# Resque.redis设置几种方式
a). Resque.redis = $redis

b). Resque.redis = 'localhost:6379'

c). vim config/resque.yml
内容:
development: localhost:6379
test: localhost:6379
staging: redis1.se.github.com:6379
fi: localhost:6379
production: redis1.ae.github.com:6379

#接着 vim config/initializers/load_resque.rb 添加如下内容
rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..'
rails_env = ENV['RAILS_ENV'] || 'development'

resque_config = YAML.load_file(rails_root + '/config/resque.yml')
Resque.redis = resque_config[rails_env]

3.启动redis-server
$〉 sudo redis-server /etc/redis/redis.conf

4.测试运转
a) scaffold: ./script/server scaffold post title:string body:text

b) 迁移: rake db:migrate

c) 添加TaskJob:
vim app/models/job.rb
Notes: 'Resque jobs are any Ruby classes (or modules) which respon

read more >>

Tags: rails resque redis delayjob   Posted in Ruby & Rails

  • Search

  • Categories

    • Ruby & Rails
    • Jobs
    • Uncategorized
  • Recent Posts

    • Prawn使用Annotation坐...
    • ejabberd mod_archive
    • Capybara get session in ...
    • Juggernaut & Rails
    • RottenEgg发布
    • ruby rmagick 生成DM
    • ActiveResource for no r...
    • Rails生成Model文档
    • 转-Method triggers:inst...
    • 招聘-Ruby on Rails软件...
  • Links

    • RailsCasts
    • The Ruby Reflector
    • Alltop Ruby
    • Command Line Refer
    • Ruby Code Snippets
    • GitHub
    • API Dock
    • OpenSourceRails
    • RailsPlugins
    • RailsLab
    • 15DaysOfJQuery
  • Archives

    • 2012年(1)

    • 2012年01月(1)
    • 2011年(10)

    • 2011年12月(1)
    • 2011年11月(1)
    • 2011年08月(2)
    • 2011年04月(2)
    • 2011年03月(1)
    • 2011年01月(3)
    • 2010年(27)

    • 2010年12月(1)
    • 2010年11月(2)
    • 2010年10月(4)
    • 2010年09月(7)
    • 2010年08月(1)
    • 2010年07月(5)
    • 2010年06月(1)
    • 2010年04月(6)
    • 2009年(13)

    • 2009年10月(1)
    • 2009年05月(2)
    • 2009年04月(1)
    • 2009年03月(2)
    • 2009年02月(7)
    • 2008年(19)

    • 2008年08月(1)
    • 2008年07月(1)
    • 2008年06月(1)
    • 2008年05月(3)
    • 2008年04月(1)
    • 2008年03月(2)
    • 2008年02月(10)

Copyright © 2010 elvuel.com Powered by Elvuel.