<commit_before>module ManagedServiceOnAction
  def on_start(event_hash)
    SystemDebug.debug(SystemDebug.container_events,:ON_start_MS,event_hash)
    super
    service_configurations = @container_api.get_pending_service_configurations_hashes({service_name: @container_name, publisher_namespace: @publisher_namespace, type_path: @type_path })
    if service_configurations.is_a?(Array)
      service_configurations.each do |configuration|
        @container_api.update_service_configuration(configuration)
      end
    end
    reregister_consumers
    SystemDebug.debug(SystemDebug.container_events,:ON_start_complete_MS,event_hash)
  rescue StandardError => e
    log_exception(e)
  end

  def on_create(event_hash)
    SystemDebug.debug(SystemDebug.container_events,:ON_Create_MS,event_hash)
    super
    wait_for_startup
    @container_api.load_and_attach_post_services(self)
    service_configurations = @container_api.get_service_configurations_hashes({service_name: @container_name, publisher_namespace: @publisher_namespace, type_path: @type_path})
    if service_configurations.is_a?(Array)
      service_configurations.each do |configuration|
        next if configuration[:no_save] == true
        run_configurator(configuration)
      end
    end

    reregister_consumers
    SystemDebug.debug(SystemDebug.container_events,:ON_Create_MS_compl,event_hash)
  rescue StandardError => e
    log_exception(e)
  end

  def wait_for_startup
    n=0
    while n < 4
      n = n + 1
      sleep(0.5) unless is_startup_complete?
    end
  end
  
  def on_stop(what)
    super<commit_msg>wait for startup prior to applying consumers<commit_after>module ManagedServiceOnAction
  def on_start(event_hash)
    SystemDebug.debug(SystemDebug.container_events,:ON_start_MS,event_hash)
    super
    wait_for_startup
    service_configurations = @container_api.get_pending_service_configurations_hashes({service_name: @container_name, publisher_namespace: @publisher_namespace, type_path: @type_path })
    if service_configurations.is_a?(Array)
      service_configurations.each do |configuration|
        @container_api.update_service_configuration(configuration)
      end
    end
    reregister_consumers
    SystemDebug.debug(SystemDebug.container_events,:ON_start_complete_MS,event_hash)
  rescue StandardError => e
    log_exception(e)
  end

  def on_create(event_hash)
    SystemDebug.debug(SystemDebug.container_events,:ON_Create_MS,event_hash)
    super

    @container_api.load_and_attach_post_services(self)
    service_configurations = @container_api.get_service_configurations_hashes({service_name: @container_name, publisher_namespace: @publisher_namespace, type_path: @type_path})
    if service_configurations.is_a?(Array)
      service_configurations.each do |configuration|
        next if configuration[:no_save] == true
        run_configurator(configuration)
      end
    end

    reregister_consumers
    SystemDebug.debug(SystemDebug.container_events,:ON_Create_MS_compl,event_hash)
  rescue StandardError => e
    log_exception(e)
  end

  def wait_for_startup
    n=0
    while n < 4
      n = n + 1
      sleep(0.5) unless is_startup_complete?
    end
  end
  
  def on_stop(what)
    super
{'fraction_non_alphanumeric': 0.06965174129353234, 'fraction_numerical': 0.003109452736318408, 'mean_word_length': 4.7859712230215825, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '137860', 'n_tokens_mistral': 1002, 'n_tokens_neox': 992, 'n_words': 159}