<commit_before>{% from "opg-docker-monitoring/map.jinja" import monitoring with context %}

include:
  - .docker


monitoring-client-project-dir:
  file.directory:
    - name: /etc/docker-compose/monitoring-client
    - user: root
    - group: root
    - mode: 0755
    - require:
      - sls: docker-compose


monitoring-client-docker-compose-yml:
  file.managed:
    - name: /etc/docker-compose/monitoring-client/docker-compose.yml
    - source: salt://opg-docker-monitoring/templates/compose-monitoring-client.yml
    - template: jinja
    - user: root
    - group: root
    - mode: 644
    - require:
      - sls: docker-compose


monitoring-client-init:
  file.managed:
    - name: /etc/init.d/docker-compose-monitoring-client
    - source: salt://opg-docker-monitoring/templates/compose-monitoring-client-init.yml
    - template: jinja
    - user: root
    - group: root
    - mode: 755
    - require:
      - sls: docker-compose


docker-compose-monitoring-client:
  service.running:
    - enable: True
    - watch:
      - file: /etc/init.d/docker-compose-monitoring-client


monitoring-client-docker-compose-up:
  cmd.run:
    - name: docker-compose -p monitoringclient up -d
    - cwd: /etc/docker-compose/monitoring-client
    - shell: /bin/bash
    - env:
      - HOME: /root
    - watch:
      - file: /etc/docker-compose/*
    - require:
      - file: monitoring-client-docker-compose-yml


{% for service in salt['pillar.get']('monitoring:client') %}
{% if 'env' in pillar['monitoring']['client'][service]  %}

/etc/docker-compose/monitoring-client/{{service}}.env:
  file.managed:
    - source: salt://opg-docker-monitoring/templates/service.env
    - template: jinja
    - user: root
    - group: root
    - mode: 644
    - context:
        project: 'client'
        service: {{service}}
    - require:
      - sls: docker-compose
      - file: monitoring-client-project-dir

{% endif %}
{% endfor %}
<commit_msg>Removed docker-compose cmd.run as it conflicts the init script.  Added dependencies so that service starts on first run of this state.<commit_after>{% from "opg-docker-monitoring/map.jinja" import monitoring with context %}

include:
  - .docker


monitoring-client-project-dir:
  file.directory:
    - name: /etc/docker-compose/monitoring-client
    - user: root
    - group: root
    - mode: 0755
    - require:
      - sls: docker-compose


monitoring-client-docker-compose-yml:
  file.managed:
    - name: /etc/docker-compose/monitoring-client/docker-compose.yml
    - source: salt://opg-docker-monitoring/templates/compose-monitoring-client.yml
    - template: jinja
    - user: root
    - group: root
    - mode: 644
    - require:
      - sls: docker-compose
      - file: monitoring-client-project-dir


monitoring-client-init:
  file.managed:
    - name: /etc/init.d/docker-compose-monitoring-client
    - source: salt://opg-docker-monitoring/templates/compose-monitoring-client-init.yml
    - template: jinja
    - user: root
    - group: root
    - mode: 755
    - require:
      - sls: docker-compose


docker-compose-monitoring-client:
  service.running:
    - enable: True
    - watch:
      - file: monitoring-client-init
      - file: monitoring-client-docker-compose-yml


{% for service in salt['pillar.get']('monitoring:client') %}
{% if 'env' in pillar['monitoring']['client'][service]  %}

/etc/docker-compose/monitoring-client/{{service}}.env:
  file.managed:
    - source: salt://opg-docker-monitoring/templates/service.env
    - template: jinja
    - user: root
    - group: root
    - mode: 644
    - context:
        project: 'client'
        service: {{service}}
    - require:
      - sls: docker-compose
      - file: monitoring-client-project-dir
    - require_in:
      - service: docker-compose-monitoring-client

{% endif %}
{% endfor %}

{'fraction_non_alphanumeric': 0.13785845830044724, 'fraction_numerical': 0.0068403051828466194, 'mean_word_length': 2.504147465437788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3808660', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1262, 'n_words': 238}