Sha256: f994ec5fc8a7e3464fbc03239be97e2e699bb7fe4cb470173b3ef8f087fab027

Contents?: true

Size: 545 Bytes

Versions: 2

Compression:

Stored size: 545 Bytes

Contents

#!/usr/bin/env ruby

require "legion"
#require_relative "../lib/legion"

class Example < Legion::Object

  after_fork do
    puts "object is running in a new process"
  end

  def work(index)
    duration = rand(4)
    puts "working on: #{index} ... sleeping for #{duration} seconds"
    sleep duration
  end
end

def run_example
  puts "Starting 4 processes to run the demo."
  supervisor = Legion::Supervisor.new(Example, processes: 4, port: 52042)
  supervisor.start
  100.times { |i| supervisor.work(i) }
  supervisor.stop
end

run_example

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
legion-0.1.2 bin/legion_demo
legion-0.1.1 bin/legion_demo