Class: OpenC3::PluginMicroservice

Inherits:
Microservice show all
Defined in:
lib/openc3/microservices/plugin_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, #microservice_cmd, run, #setup_microservice_topic, #shutdown

Constructor Details

#initialize(name) ⇒ PluginMicroservice

Returns a new instance of PluginMicroservice.



28
29
30
# File 'lib/openc3/microservices/plugin_microservice.rb', line 28

def initialize(name)
  super(name, is_plugin: true)
end

Instance Method Details

#runObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/openc3/microservices/plugin_microservice.rb', line 32

def run
  Dir.chdir @work_dir
  begin
    if @config["cmd"][0] != 'ruby'
      # Try to make sure the cmd is executable
      FileUtils.chmod 0777, @config["cmd"][0]
    end
  rescue Exception
    # Its ok if this fails
  end

  # Fortify: Process Control
  # This is dangerous! However, plugins need to be able to run whatever they want.
  # Only admins can install plugins and they need to be vetted for content.
  # NOTE: In OpenC3 EE each microservice gets its own container so the potential
  # footprint is much smaller. In OpenSource OpenC3 you're in the same container
  # as all the other plugins.
  exec(*@config["cmd"])
end