Class: OpenC3::MultiMicroservice
- Inherits:
-
Microservice
- Object
- Microservice
- OpenC3::MultiMicroservice
- Defined in:
- lib/openc3/microservices/multi_microservice.rb
Instance Attribute Summary
Attributes inherited from Microservice
#count, #custom, #error, #logger, #microservice_status_thread, #name, #scope, #secrets, #state
Instance Method Summary collapse
Methods inherited from Microservice
#as_json, #initialize, #microservice_cmd, run, #setup_microservice_topic
Constructor Details
This class inherits a constructor from OpenC3::Microservice
Instance Method Details
#run ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/openc3/microservices/multi_microservice.rb', line 24 def run @threads = [] ARGV.each do |microservice_name| microservice_model = MicroserviceModel.get_model(name: microservice_name, scope: @scope) @threads << Thread.new do cmd_line = microservice_model.cmd.join(' ') split_cmd_line = cmd_line.split(' ') filename = nil split_cmd_line.each do |item| if File.extname(item) == '.rb' filename = item break end end raise "Could not determine class filename from '#{cmd_line}'" unless filename OpenC3.set_working_dir(@work_dir) do require_relative filename end klass = filename.filename_to_class_name.to_class klass.run(microservice_model.name) end end @threads.each do |thread| thread.join end end |
#shutdown ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/openc3/microservices/multi_microservice.rb', line 51 def shutdown super() if @threads @threads.each do |thread| thread.join end end end |