Heroku dyno/worker在启动时崩溃 [英] Heroku dyno/worker crashes at start

查看:138
本文介绍了Heroku dyno/worker在启动时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用Rails编写的应用程序,已部署在Heroku上.我曾经使用过1种Web dynos,但是今天我发布了该应用程序,因为流量很大,所以我决定将它增加到4种Web dynos和1种worker dynos.我不知道为什么总是在显示 heroku ps 时显示:

 进程状态命令-------- -------------- ---------------------------------web.1 up for 22s bundle exec rails服务器-p $ PORTweb.2升级为36s捆绑exec rails服务器-p $ PORTweb.3 up for 25s bundle exec rails server -p $ PORTweb.4 up for 22s bundle exec rails server -p $ PORTworker.1因7s bundle exec rake工作而崩溃:工作 

Worker dyno在 heroku scale worker = 1 之后直接崩溃.日志就像:

  2012-03-11T23:12:18 + 00:00 heroku [worker.1]:使用命令`bundle exec rake jobs:work`启动进程2012-03-11T23:12:19 + 00:00 heroku [worker.1]:状态从开始更改为开始2012-03-11T23:12:22 + 00:00应用程序[worker.1]:耙子中止了!2012-03-11T23:12:22 + 00:00 app [worker.1]:不知道如何构建任务'jobs:work'2012-03-11T23:12:22 + 00:00 app [worker.1]:2012-03-11T23:12:22 + 00:00 app [worker.1] :(通过运行带有--trace的任务来查看完整的跟踪)2012-03-11T23:12:23 + 00:00 heroku [worker.1]:进程退出,状态为12012-03-11T23:12:23 + 00:00 heroku [worker.1]:状态从更改为崩溃2012-03-11T23:12:23 + 00:00 heroku [worker.1]:状态从崩溃更改为已创建2012-03-11T23:12:23 + 00:00 heroku [worker.1]:状态从创建更改为开始2012-03-11T23:12:32 + 00:00 heroku [worker.1]:使用命令`bundle exec rake jobs:work`启动进程2012-03-11T23:12:32 + 00:00 heroku [worker.1]:状态从开始更改为开始2012-03-11T23:12:36 + 00:00应用程序[worker.1]:耙子中止了!2012-03-11T23:12:36 + 00:00 app [worker.1]:不知道如何构建任务'jobs:work'2012-03-11T23:12:36 + 00:00 app [worker.1]:2012-03-11T23:12:36 + 00:00 app [worker.1] :(通过使用--trace运行任务来查看完整跟踪)2012-03-11T23:12:37 + 00:00 heroku [worker.1]:进程退出,状态为12012-03-11T23:12:37 + 00:00 heroku [worker.1]:状态从更改为崩溃 

就是这样.你知道为什么吗网络测功机工作正常.我必须在我的应用程序中配置某些内容才能使用辅助测功机吗?

如果您能用人类的语言来解释我,我也将不胜感激,将heroku平台分为网络和工作者动态是什么逻辑?我已经阅读了很多次文档,但是我仍然觉得我在了解存储空间和存储空间的过程中错过了理解的重点.

解决方案

工作人员用于后台处理,例如,发送电子邮件,从某些Web服务获取数据,通常用于需要很长时间的任何任务,而您不想让您的用户等待它查看页面.这种想法应该用于提高性能,因为如果您使用Web dynos来发送10封电子邮件,那时候它们就没有响应用户的请求了,因此您就无法处理那么多用户.

必须排队排队,工作人员应检查该队列以完成该工作!

因此,您的工作人员由于未定义任何作业而崩溃,因此他可以等待该作业的队列.检查此gem,以获取有关如何设置作业和排队任务的信息.

https://github.com/defunkt/resque

工作者可以用来做的另一件事是安排某些任务,例如cron作业.这是帮助方面的瑰宝.

https://github.com/javan/whenever

我强烈建议您也在RailsCasts上观看此视频

http://railscasts.com/episodes/171-delayed-job

http://railscasts.com/episodes/271-resque

I have an application written in Rails, deployed on Heroku. I used to have been working on 1 web dyno, but today I have published the app, the traffic is quite big so I decided to increase to 4 web dynos and 1 worker dynos. I don't know why always when I do heroku ps it shows:

Process   State           Command                            
--------  --------------  ---------------------------------  
web.1     up for 22s      bundle exec rails server -p $PORT  
web.2     up for 36s      bundle exec rails server -p $PORT  
web.3     up for 25s      bundle exec rails server -p $PORT  
web.4     up for 22s      bundle exec rails server -p $PORT  
worker.1  crashed for 7s  bundle exec rake jobs:work

Worker dyno crashes directly after heroku scale worker=1. Logs are like:

2012-03-11T23:12:18+00:00 heroku[worker.1]: Starting process with command `bundle exec rake jobs:work`
2012-03-11T23:12:19+00:00 heroku[worker.1]: State changed from starting to up
2012-03-11T23:12:22+00:00 app[worker.1]: rake aborted!
2012-03-11T23:12:22+00:00 app[worker.1]: Don't know how to build task 'jobs:work'
2012-03-11T23:12:22+00:00 app[worker.1]: 
2012-03-11T23:12:22+00:00 app[worker.1]: (See full trace by running task with --trace)
2012-03-11T23:12:23+00:00 heroku[worker.1]: Process exited with status 1
2012-03-11T23:12:23+00:00 heroku[worker.1]: State changed from up to crashed
2012-03-11T23:12:23+00:00 heroku[worker.1]: State changed from crashed to created
2012-03-11T23:12:23+00:00 heroku[worker.1]: State changed from created to starting
2012-03-11T23:12:32+00:00 heroku[worker.1]: Starting process with command `bundle exec rake jobs:work`
2012-03-11T23:12:32+00:00 heroku[worker.1]: State changed from starting to up
2012-03-11T23:12:36+00:00 app[worker.1]: rake aborted!
2012-03-11T23:12:36+00:00 app[worker.1]: Don't know how to build task 'jobs:work'
2012-03-11T23:12:36+00:00 app[worker.1]: 
2012-03-11T23:12:36+00:00 app[worker.1]: (See full trace by running task with --trace)
2012-03-11T23:12:37+00:00 heroku[worker.1]: Process exited with status 1
2012-03-11T23:12:37+00:00 heroku[worker.1]: State changed from up to crashed

That's it. Do you have any idea why? Web dynos are working properly. Do I have to configure something in my app to use worker dynos?

I would be also grateful if you can explain me in human words what is the logic behind dividing the heroku platform into web and worker dynos? I have read documentation number of times but I still think I missing the point to understand it as I grew up in the world where you had your storage limit and stuff.

解决方案

Workers are used for background processing, for example, sending e-mails, fetching data from some web service, in general it's for any task that takes long and you don't want your user to wait for it to see the page. This is a think that should be used for performance, because if you are using web dynos for sending like 10 e-mails, that's time that they aren't responding to user request, so you can't handle so many users.

Taks must be queued and workers should check that queue to get that job done!

So your worker crashs because you don't have any job defined, so he can waits for queues on that job. Check this gem for information on how to set a job and queue tasks.

https://github.com/defunkt/resque

Another thing that workers can be used for it's to schedule some task, like cron jobs. Here is a gem for help on that.

https://github.com/javan/whenever

I highly recommend you to watch this too videos on RailsCasts

http://railscasts.com/episodes/171-delayed-job

http://railscasts.com/episodes/271-resque

这篇关于Heroku dyno/worker在启动时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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