Skip to content

mikemarsian/serially-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serially-Demo

This is a rails demo app the demonstrates how Serially gem can be used to orchestrate background tasks to run serially, one after another, for instances of a model.

Installation

$ bundle

The following generates a migration that creates serially_task_runs table, which would be used to write the results of all your task runs.

$ rails generate serially:install
$ rake db:migrate

For resque, you'll need to make sure that redis is installed and running:

$ redis-cli ping   # should return PONG

If redis isn't installed, get it here

Usage

Run

Run web-server:

    $ rails s

Run resque

    # this will start 3 resque workers that will listen to the 'posts' queue
    $ bundle exec rake resque:workers QUEUE='posts' COUNT=3 TERM_CHILD=1

Go to localhost:3000, create a new post, and click the Schedule Serially Tasks link next to it. For the sake of an experiment, you can click the link multiple times, the tasks for the post will still run only once.

View Results

Give it 15 seconds, refresh localhost:3000, and you should see the columns Drafted by, Reviewed by, and Published By filled with values. Last task columns display info on the last task that ran for each post.

Monitor

  • Go to localhost:3000/resque to see a job being added to serially queue for every post on which you click Schedule Serially Tasks
  • Monitor the resque log to see what's going on:
    $ tail -f ./log/resque.log

About

Demo app that showcases Serially gem usage

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published