Class: StellarCoreCommander::Commander
- Inherits:
-
Object
- Object
- StellarCoreCommander::Commander
- Includes:
- Contracts
- Defined in:
- lib/stellar_core_commander/commander.rb
Instance Method Summary collapse
- #cleanup ⇒ Object
- #cleanup_at_exit! ⇒ Object
-
#initialize(stellar_core_bin) ⇒ Commander
constructor
A new instance of Commander.
- #make_process ⇒ Object
Constructor Details
#initialize(stellar_core_bin) ⇒ Commander
Returns a new instance of Commander.
10 11 12 13 14 15 |
# File 'lib/stellar_core_commander/commander.rb', line 10 def initialize(stellar_core_bin) @stellar_core_bin = stellar_core_bin raise "no file at #{stellar_core_bin}" unless File.exist?(stellar_core_bin) @processes = [] end |
Instance Method Details
#cleanup ⇒ Object
31 32 33 |
# File 'lib/stellar_core_commander/commander.rb', line 31 def cleanup @processes.each(&:cleanup) end |
#cleanup_at_exit! ⇒ Object
35 36 37 38 39 40 |
# File 'lib/stellar_core_commander/commander.rb', line 35 def cleanup_at_exit! at_exit do $stderr.puts "cleaning up #{@processes.length} processes" cleanup end end |
#make_process ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/stellar_core_commander/commander.rb', line 18 def make_process tmpdir = Dir.mktmpdir("scc") identity = Stellar::KeyPair.random base_port = 39132 + (@processes.length * 2) FileUtils.cp(@stellar_core_bin, "#{tmpdir}/stellar-core") Process.new(tmpdir, base_port, identity).tap do |p| p.setup @processes << p end end |