简体   繁体   中英

Deploying background worker for rails like Resque into CloudFoundry

Currently working on building a live dashboard with Rails which needs a background processing to keep polling for data every now and then to keep the dashboard afresh. I am able to achieve that with Resque, Resque-Scheduler and Redis Server and works fine locally . All the code is baked into Rails app, for example, if user visits the dashboard page, inside the dashboard_controller I queue the job like this

Resque.enqueue(BackgroundJob, params)

And I have the worker performing the job from app/worker/background_job.rb

class BackgroundJob
  @queue = :backgroundq

  def self.perform
    < PERFORM CODE HERE>
  end
end

Problem:

When I had to deploy into Cloudfoundry it instructs me to deploy the same code twice in different names 1. as a Rails app (Web Process) 2. as a Ruby no-route app for the background worker binding to the same Redis service on the cloud. I dont understand the process here, if they live in two different app spaces and how they communicate to each other ? because I need to communicate lots of data back and forth. For sure I am lacking some basic application architecture design. Can someone explain how would I go about this?

Yes you miss something because rails app and worker it's different process. When you call Resque.enqueue(BackgroundJob, params) you communicate with worker via redis. So if you want to communicate back you must use something like redis or postgres or event text file.

Can you get more information about your task?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM