Matt Mower <matt.mower / gmail.com> wrote:
> I don't know if this is possible or not but I seem to remember that
> irb has job control.  Could you maybe start your app from within irb,
> either as a background job or maybe by spawning it in a thread?

Oh.  I can't figure out how to run something as a background job:

irb(main):001:0> irb # new job
irb#1(main):001:0> booga = "booga"
=> "booga"
irb#1(main):002:0> while true; p booga; sleep 2; end
"booga"
"booga"
"booga"
"booga"
IRB::Abort: abort then interrupt!!
        from /usr/lib/ruby/1.8/irb.rb:81
irb#1(main):003:0>

It's in the foreground and if I press Control-C, it aborts.  Control-Z
suspends the IRB process itself.  Is there some way of backgrounding a
job so that variables can be modified?

I can run it in a new thread like this:

irb(main):001:0> booga = "booga"
=> "booga"
irb(main):002:0> x = Thread.new { while true; p booga; sleep 2; end }
"booga"=> #<Thread:0x402caab0 run>
irb(main):003:0>
"booga"
"booga"

irb(main):004:0* jobs
=> #0->irb on main (#<Thread:0x4029f798>: running)
irb(main):005:0> booga = "blah"
=> "blah"
irb(main):006:0> "blah"
"blah"

That seems to work.  Is irb a robust solution?

Thanks,
Navin.