<commit_before>nginx:
  pkg:
    - installed
  service:
    - running
    - require:
      - service: uwsgi
      - pkg: nginx

postgresql:
  pkg:
    - installed
  service:
    - running
    - require:
      - pkg: postgresql

coffeestats-dependencies:
  pkg.installed:
    - pkgs:
      - libpq-dev
      - python
      - python-dev
      - python-virtualenv
      - virtualenv
      - libffi-dev
      - xvfb
      - iceweasel

/etc/uwsgi/apps-available/coffeestats.ini:
  file.managed:
    - user: root
    - group: root
    - mode: 0644
    - source: salt://coffeestats/coffeestats.uwsgi.ini
    - template: jinja

/etc/uwsgi/apps-enabled/coffeestats.ini:
  file.symlink:
    - target: /etc/uwsgi/apps-available/coffeestats.ini
    - require:
      - file: /etc/uwsgi/apps-available/coffeestats.ini

coffeestats-venv:
  cmd.run:
    - name: virtualenv --python=/usr/bin/python2 /home/vagrant/coffeestats-venv
    - user: vagrant
    - group: vagrant
    - creates: /home/vagrant/coffeestats-venv
    - require:
      - pkg: coffeestats-dependencies

coffeestats-requires:
  cmd.run:
    - name: /home/vagrant/coffeestats-venv/bin/pip install -r requirements/local.txt
    - user: vagrant
    - group: vagrant
    - cwd: /vagrant
    - require:
      - cmd: coffeestats-venv
      - pkg: coffeestats-dependencies
    - watch_in:
      - service: uwsgi

coffeestats-static:
  cmd.run:
    - name: . /home/vagrant/csdev.sh ; /home/vagrant/coffeestats-venv/bin/python manage.py collectstatic --noinput
    - user: vagrant
    - group: vagrant
    - cwd: /vagrant/coffeestats
    - require:
      - cmd: coffeestats-requires
      - file: /home/vagrant/csdev.sh

uwsgi-coffeestats:
  pkg.installed:
    - names:
      - uwsgi
      - uwsgi-plugin-python
  service.running:
    - name: uwsgi
    - enable: True
    - reload: True
    - sig: uwsgi
    - require:
      - pkg: uwsgi
      - pkg: uwsgi-plugin-python
      - file: /etc/uwsgi/apps-enabled/coffeestats.ini
      - cmd: coffeestats-requires
      - cmd: coffeestats-static
    - watch:
      - file: /etc/uwsgi/apps-available/coffeestats.ini
    - watch_in:
      - service: nginx

/home/vagrant/csdev.sh:
  file.managed:
    - user: vagrant
    - group: vagrant
    - mode: 0644
    - template: jinja
    - source: salt://coffeestats/csdev.sh<commit_msg>Restart uwsgi to make sure it is running<commit_after>nginx:
  pkg:
    - installed
  service:
    - running
    - require:
      - service: uwsgi
      - pkg: nginx

postgresql:
  pkg:
    - installed
  service:
    - running
    - require:
      - pkg: postgresql

coffeestats-dependencies:
  pkg.installed:
    - pkgs:
      - libpq-dev
      - python
      - python-dev
      - python-virtualenv
      - virtualenv
      - libffi-dev
      - xvfb
      - iceweasel

/etc/uwsgi/apps-available/coffeestats.ini:
  file.managed:
    - user: root
    - group: root
    - mode: 0644
    - source: salt://coffeestats/coffeestats.uwsgi.ini
    - template: jinja

/etc/uwsgi/apps-enabled/coffeestats.ini:
  file.symlink:
    - target: /etc/uwsgi/apps-available/coffeestats.ini
    - require:
      - file: /etc/uwsgi/apps-available/coffeestats.ini

coffeestats-venv:
  cmd.run:
    - name: virtualenv --python=/usr/bin/python2 /home/vagrant/coffeestats-venv
    - user: vagrant
    - group: vagrant
    - creates: /home/vagrant/coffeestats-venv
    - require:
      - pkg: coffeestats-dependencies

coffeestats-requires:
  cmd.run:
    - name: /home/vagrant/coffeestats-venv/bin/pip install -r requirements/local.txt
    - user: vagrant
    - group: vagrant
    - cwd: /vagrant
    - require:
      - cmd: coffeestats-venv
      - pkg: coffeestats-dependencies
    - watch_in:
      - service: uwsgi

coffeestats-static:
  cmd.run:
    - name: . /home/vagrant/csdev.sh ; /home/vagrant/coffeestats-venv/bin/python manage.py collectstatic --noinput
    - user: vagrant
    - group: vagrant
    - cwd: /vagrant/coffeestats
    - require:
      - cmd: coffeestats-requires
      - file: /home/vagrant/csdev.sh

uwsgi-coffeestats:
  pkg.installed:
    - names:
      - uwsgi
      - uwsgi-plugin-python
  service.running:
    - name: uwsgi
    - enable: True
    - full_restart: True
    - sig: uwsgi
    - require:
      - pkg: uwsgi
      - pkg: uwsgi-plugin-python
      - file: /etc/uwsgi/apps-enabled/coffeestats.ini
      - cmd: coffeestats-requires
      - cmd: coffeestats-static
    - watch:
      - file: /etc/uwsgi/apps-available/coffeestats.ini
    - watch_in:
      - service: nginx

/home/vagrant/csdev.sh:
  file.managed:
    - user: vagrant
    - group: vagrant
    - mode: 0644
    - template: jinja
    - source: salt://coffeestats/csdev.sh
{'fraction_non_alphanumeric': 0.11837872614196869, 'fraction_numerical': 0.0038601758524555007, 'mean_word_length': 1.9897435897435898, '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': '4537252', 'n_tokens_mistral': 1871, 'n_tokens_neox': 1767, 'n_words': 298}