Ruby app and Resque: can't start workers

henritroyat

I have this small ruby application, not Ruby on Rails - pure Ruby.

I've followed the instructions and I can queue stuff and see that everything is correctly queued using resque-web.

However, I have a problem to start a worker. The documentation indicates to run bin/resque work to launch a worker.

Doing so triggers the message -bash: bin/resque: No such file or directory

Everywhere on the Internet, people have the same problem, but for Rails app, not pure Ruby. The solution seems to include something in the rakefile, which I don't have.

How can I launch my worker? Thanks a lot!

wkjagt

The key to solving your problem is rake.

Resque includes three rake tasks. All you need is a rakefile that requires 'resque/tasks' to use them. When you ask Rake for its list of commands you'll see the three tasks that are included with Resque:

rake resque:failures:sort  # Sort the 'failed' queue for the redis_multi_queue failure backend
rake resque:work           # Start a Resque worker
rake resque:workers        # Start multiple Resque workers

The one you're looking for (to start one worker) is resque:work. You tell it which queue to listen to using the QUEUE environment variable. So starting your worker would be something like:

QUEUE=your_queue_name rake resque:work.

Alternatively, you can listen to all queues using QUEUES=*.

EDIT:

Here's a more complete example. Create a file called rakefile:

require 'resque/tasks'
require 'resque'

class Worker
  @queue = :default

  def self.perform(my_arg)
    puts my_arg
  end
end

task :hello do
    Resque.enqueue(Worker, 'hello')
end

Then in one terminal type TERM_CHILD=1 QUEUE=default rake resque:work. This will start the worker, watching the queue called default. It will print out any argument a job passes to its perform class method.

In a second terminal type rake hello. This will enqueue a job for the Worker class, passing the string hello as an argument (which will be passed to the perform method in the Worker class). It knows to push to the default queue by looking at the @queue property on Worker.

You'll see hello printed in the terminal where you started the worker.

This example doesn't do anything useful, and you wouldn't put all that in your rakefile, but I think it's a good starting point for you to start modifying it and build your own.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Can't start accounts app using django-userena

분류에서Dev

Can't start Byobu?

분류에서Dev

Can't start bundled Meteor app: "Error: failed to connect to [127.0.0.1:3001]"

분류에서Dev

Ruby Resque, @queue 인스턴스 변수

분류에서Dev

Ruby Resque, @queue 인스턴스 변수

분류에서Dev

apache2 can't stop and nginx can't start

분류에서Dev

I can't start a new project on Netbeans

분류에서Dev

can't start mysql service anymore

분류에서Dev

can't start calligra on linux xfce

분류에서Dev

Ubuntu Service samba is masked and can't start

분류에서Dev

Can't start MySQL server (database corruption)

분류에서Dev

can't start lightdm without systemctl

분류에서Dev

Can't update database inside of ruby loop

분류에서Dev

Cordova won't start Safari, shows website in app

분류에서Dev

Can't run app on Android device

분류에서Dev

Can't uninstall postgresql package due failing to start service?

분류에서Dev

Can't start up Ubuntu after restarting to complete installation

분류에서Dev

Android external app can't access app's files

분류에서Dev

Ruby File.open can't convert nil into String (TypeError)

분류에서Dev

Ruby Beginner: Can't Get Created Methods To Work

분류에서Dev

MongoDB Ruby driver - `synchronize': can't be called from trap context

분류에서Dev

Ruby module include, can't access included methods, only constants

분류에서Dev

Can't install a Ruby package: Failed to build gem native extension

분류에서Dev

I install ubuntu 13.10 but the Pc can't start up ubuntu it start with windows

분류에서Dev

How to start the snapcraft app?

분류에서Dev

Can I change the icon of a Chrome app pinned to the start menu in Windows 10?

분류에서Dev

I can't run Qt app on other mac

분류에서Dev

I can't run my mobile app on worklight development server

분류에서Dev

Can't make my app appear in the chooser Android BROWSABLE

Related 관련 기사

  1. 1

    Can't start accounts app using django-userena

  2. 2

    Can't start Byobu?

  3. 3

    Can't start bundled Meteor app: "Error: failed to connect to [127.0.0.1:3001]"

  4. 4

    Ruby Resque, @queue 인스턴스 변수

  5. 5

    Ruby Resque, @queue 인스턴스 변수

  6. 6

    apache2 can't stop and nginx can't start

  7. 7

    I can't start a new project on Netbeans

  8. 8

    can't start mysql service anymore

  9. 9

    can't start calligra on linux xfce

  10. 10

    Ubuntu Service samba is masked and can't start

  11. 11

    Can't start MySQL server (database corruption)

  12. 12

    can't start lightdm without systemctl

  13. 13

    Can't update database inside of ruby loop

  14. 14

    Cordova won't start Safari, shows website in app

  15. 15

    Can't run app on Android device

  16. 16

    Can't uninstall postgresql package due failing to start service?

  17. 17

    Can't start up Ubuntu after restarting to complete installation

  18. 18

    Android external app can't access app's files

  19. 19

    Ruby File.open can't convert nil into String (TypeError)

  20. 20

    Ruby Beginner: Can't Get Created Methods To Work

  21. 21

    MongoDB Ruby driver - `synchronize': can't be called from trap context

  22. 22

    Ruby module include, can't access included methods, only constants

  23. 23

    Can't install a Ruby package: Failed to build gem native extension

  24. 24

    I install ubuntu 13.10 but the Pc can't start up ubuntu it start with windows

  25. 25

    How to start the snapcraft app?

  26. 26

    Can I change the icon of a Chrome app pinned to the start menu in Windows 10?

  27. 27

    I can't run Qt app on other mac

  28. 28

    I can't run my mobile app on worklight development server

  29. 29

    Can't make my app appear in the chooser Android BROWSABLE

뜨겁다태그

보관