如何在生产中部署 resque 工人? [英] How to deploy resque workers in production?

查看:20
本文介绍了如何在生产中部署 resque 工人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GitHub 的家伙最近发布了他们使用 Redis 的后台处理应用程序:http://github.com/defunkt/resquehttp://github.com/blog/542-introducing-resque

The GitHub guys recently released their background processing app which uses Redis: http://github.com/defunkt/resque http://github.com/blog/542-introducing-resque

我让它在本地工作,但我正在努力让它在生产中工作.有没有人有:

I have it working locally, but I'm struggling to get it working in production. Has anyone got a:

  1. Capistrano 部署工人的秘诀(控制工人数量,重新启动他们等)
  2. 已部署的工作器将机器与运行主应用的机器分开,这里需要哪些设置?
  3. 在服务器重新启动后获得了 redis(我尝试将其放入 cron 但没有成功)
  4. 您是如何将 resque-web(他们出色的监控应用程序)应用到您的部署中的?

谢谢!

附言我在 Github 上发布了一个关于这个的问题,但还没有回应.希望一些 SO 大师可以帮助解决这个问题,因为我在部署方面不是很有经验.谢谢!

P.S. I posted an issue on Github about this but no response yet. Hoping some SO gurus can help on this one as I'm not very experienced in deployments. Thank you!

推荐答案

Garrett 的回答真的很有帮助,只是想发布更多细节.花了很多功夫才把它弄对...

Garrett's answer really helped, just wanted to post a few more details. It took a lot of tinkering to get it right...

我也在使用乘客,但使用 nginx 而不是 apache.

I'm using passenger also, but nginx instead of apache.

首先,不要忘记你需要安装 sinatra,这让我有一阵子不明白.sudo gem 安装 sinatra

First, don't forget you need to install sinatra, this threw me for a while. sudo gem install sinatra

然后你需要为这个东西创建一个目录来运行,它必须有一个public和tmp文件夹.它们可以为空,但问题是 git 不会在 repo 中保存空目录.目录中必须至少有一个文件,所以我制作了一些垃圾文件作为占位符.这是 git 中的一个奇怪的功能/错误.

Then you need to make a directory for the thing to run, and it has to have a public and tmp folder. They can be empty but the problem is that git won't save an empty directory in the repo. The directory has to have at least one file in it, so I made some junk files as placeholders. This is a weird feature/bug in git.

我正在使用 resque 插件,所以我在那里创建了目录(默认 config.ru 所在的位置).看起来 Garrett 在他的 rails_root 中创建了一个新的resque"目录.任何一个都应该工作.对我来说...

I'm using the resque plugin, so I made the directory there (where the default config.ru is). It looks like Garrett made a new 'resque' directory in his rails_root. Either one should work. For me...

cd MY_RAILS_APP/vendor/plugins/resque/
mkdir public 
mkdir tmp
touch public/placeholder.txt
touch tmp/placeholder.txt

然后我编辑了MY_RAILS_APP/vendor/plugins/resque/config.ru,看起来像这样:

Then I edited MY_RAILS_APP/vendor/plugins/resque/config.ru so it looks like this:

#!/usr/bin/env ruby
require 'logger'

$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/lib')
require 'resque/server'

use Rack::ShowExceptions

# Set the AUTH env variable to your basic auth password to protect Resque.
AUTH_PASSWORD = "ADD_SOME_PASSWORD_HERE"
if AUTH_PASSWORD
  Resque::Server.use Rack::Auth::Basic do |username, password|
    password == AUTH_PASSWORD
  end
end

run Resque::Server.new

不要忘记将 ADD_SOME_PASSWORD_HERE 更改为您要用于保护应用的密码.

Don't forget to change ADD_SOME_PASSWORD_HERE to the password you want to use to protect the app.

最后,我使用的是 Nginx 所以这是我添加到我的 nginx.conf 中的内容

Finally, I'm using Nginx so here is what I added to my nginx.conf

server {
  listen   80;
  server_name  resque.seoaholic.com;
  root /home/admin/public_html/seoaholic/current/vendor/plugins/resque/public;
  passenger_enabled on;
}

因此它会在您的部署中重新启动,可能类似于您的 deploy.rb 中的内容

And so it gets restarted on your deploys, probably something like this in your deploy.rb

run "touch #{current_path}/vendor/plugins/resque/tmp/restart.txt"

我不确定这是否是最好的方法,我以前从未设置过机架/sinatra 应用程序.但它有效.

I'm not really sure if this is the best way, I've never setup rack/sinatra apps before. But it works.

这只是为了让监控应用程序运行起来.接下来我需要弄清楚上帝的部分.

This is just to get the monitoring app going. Next I need to figure out the god part.

这篇关于如何在生产中部署 resque 工人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆