Reputation: 18018
Here is my scenario: I have some data coming into serial port. I want to keep collecting this data and store in the database. Then the rails app uses this data from the database and shows some statistics like graphs and stuff.
So my question is how can I keep collecting this data in a separate thread from the rails app, while the rest of the things work like any other rails app on the database.
If there is a better way of doing this please advice.
PS: I dont have any problem in reading from serial port. This is about doing this task from rails app in separate thread.
Upvotes: 0
Views: 594
Reputation: 11
Another thing you can check out is the resque gem which github published, it makes use of redis as a working queue, and has a very handy web interface, that helps controlling the working threads. It is very similar to delayed jobs, but may fit your needs in a better way.
Upvotes: 1
Reputation: 24617
Use the delayed_job gem.
Delayed_job (or DJ) encapsulates the common pattern of asynchronously executing longer tasks in the background.
Upvotes: 1