Method: OpenC3::ReactionModel#undeploy

Defined in:
lib/openc3/models/reaction_model.rb

#undeployObject



314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/openc3/models/reaction_model.rb', line 314

def undeploy
  return unless ReactionModel.names(scope: @scope).empty?

  model = MicroserviceModel.get_model(name: @microservice_name, scope: @scope)
  if model
    # Let the frontend know that the microservice is shutting down
    # Custom event which matches the 'deployed' event in ReactionMicroservice
    notification = {
      'kind' => 'undeployed',
      'type' => 'reaction',
      # name and updated_at fields are required for Event formatting
      'data' => JSON.generate({
        'name' => @microservice_name,
        'updated_at' => Time.now.to_nsec_from_epoch,
      }),
    }
    AutonomicTopic.write_notification(notification, scope: @scope)
    model.destroy
  end
end