Class: ASIR::Application
- Inherits:
-
Object
- Object
- ASIR::Application
- Defined in:
- lib/asir/application.rb
Overview
Ugly workaround JRuby’s lack of fork().
Defined Under Namespace
Classes: Spawn
Instance Attribute Summary collapse
-
#inc ⇒ Object
Returns the value of attribute inc.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#in_spawn? ⇒ Boolean
class.
-
#initialize ⇒ Application
constructor
A new instance of Application.
- #main ⇒ Object
- #spawn(name, &blk) ⇒ Object
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
8 9 10 11 |
# File 'lib/asir/application.rb', line 8 def initialize @inc = [ ] @name_to_spawn = { } end |
Instance Attribute Details
#inc ⇒ Object
Returns the value of attribute inc.
6 7 8 |
# File 'lib/asir/application.rb', line 6 def inc @inc end |
#verbose ⇒ Object
Returns the value of attribute verbose.
6 7 8 |
# File 'lib/asir/application.rb', line 6 def verbose @verbose end |
Instance Method Details
#in_spawn? ⇒ Boolean
class
87 88 89 90 91 92 93 94 95 |
# File 'lib/asir/application.rb', line 87 def in_spawn? return @in_spawn unless @in_spawn.nil? @in_spawn = false $stderr.puts "#{$$} ARGV = #{ARGV.inspect}" if verbose if ARGV.size >= 1 and ARGV[0] =~ /^--asir-spawn=(.*)/ @in_spawn = $1.to_sym end @in_spawn end |
#main ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/asir/application.rb', line 97 def main if in_spawn? begin name = @in_spawn if tmp = ARGV[1] out = "#{tmp}.out" run = "#{tmp}.run" $stdout = $stderr = File.open(out, "w") STDOUT.reopen($stdout); STDERR.reopen($stderr) File.open(run, "w") { | fh | fh.puts $$ } end spawn = @name_to_spawn[name] raise "#{$$} #{self} Cannot find spawn name #{name.inspect}" unless spawn spawn.blk.call ensure Process.exit!(0) end end yield if block_given? end |