瀏覽代碼

[fifteen5] Fix supervisor files

Colin Powell 4 年之前
父節點
當前提交
799f5ed822

+ 8 - 0
ansible/roles/fifteen5/files/fifteen5-fe-supervisor.conf

@@ -0,0 +1,8 @@
+[program:fifteen5-fe]
+command=/usr/local/bin/bash -lc "direnv exec /usr/local/src/fifteen5 yarn serve"
+directory=/usr/local/src/fifteen5
+autostart=true
+autorestart=true
+stdout_logfile=/var/log/supervisor-fifteen5-yarn.log
+stderr_logfile=/var/log/supervisor-fifteen5-yarn-err.log
+stopsignal=QUIT

+ 2 - 2
ansible/roles/fifteen5/files/fifteen5-supervisor.conf

@@ -2,6 +2,6 @@
 command=/usr/local/bin/bash -lc "direnv exec /usr/local/src/fifteen5 python /usr/local/src/fifteen5/manage.py runserver_plus 0.0.0.0:8000"
 autostart=true
 autorestart=true
-stdout_logfile=/var/log/fifteen5.log
-stderr_logfile=/var/log/fifteen5.err.log
+stdout_logfile=/var/log/supervisor-fifteen5.log
+stderr_logfile=/var/log/supervisor-fifteen5.err.log
 stopsignal=QUIT

+ 22 - 2
ansible/roles/fifteen5/tasks/main.yml

@@ -2,7 +2,7 @@
 - name: Dependencies installed
   # We install xmlsec and cairocffi using pkg because python-Levenshtein is tricky to install on FreeBSD
   community.general.pkgng:
-    name: git,py37-pip,vim-console,tmux,fish,direnv,jpeg-turbo,tiff,webp,lcms2,freetype2,syncthing,yarn-node14,redis,cairo,pango,gmake,libxml2,libxslt,postgresql12-client,py37-xmlsec,py37-cairocffi
+    name: git,py37-pip,vim-console,tmux,fish,direnv,jpeg-turbo,tiff,webp,lcms2,freetype2,syncthing,yarn-node14,redis,cairo,pango,gmake,libxml2,libxslt,postgresql12-client,py37-xmlsec,py37-cairocffi,py37-sqlite3
     state: latest
 
 - name: Redis enabled
@@ -75,6 +75,7 @@
     dest: /usr/local/src/fifteen5
     accept_hostkey: yes
     update: yes
+  ignore_errors: true
   tags:
     - deploy
 
@@ -84,6 +85,12 @@
     dest: /usr/local/src/fifteen5/.stignore
     mode: 0775
 
+- name: Syncthing running as root
+  shell:
+    cmd: 'sed -i -e ''/^: ${syncthing_user/s/"syncthing"/"root"/'' /usr/local/etc/rc.d/syncthing'
+    warn: false
+  notify: Syncthing restarted
+
 - name: Environment file installed
   template:
     src: envrc.j2
@@ -96,6 +103,8 @@
   shell:
     cmd: direnv allow
     chdir: /usr/local/src/fifteen5
+  tags:
+    - deploy
 
 - name: 15Five requirements up to date
   pip:
@@ -114,6 +123,7 @@
       - pgcli
       - ipython
       - git+git://github.com/sureapp/sqlformatter
+      - python-json-logger
     executable: pip
   tags:
     - deploy
@@ -124,7 +134,7 @@
   tags:
     - deploy
 
-- name: 15Five supervisor file installed
+- name: 15Five BE supervisor file installed
   copy:
     src: fifteen5-supervisor.conf
     dest: /usr/local/etc/supervisor/conf.d/
@@ -132,14 +142,24 @@
     mode: 0644
   notify: Supervisor restarted
 
+- name: 15Five FE supervisor file installed
+  copy:
+    src: fifteen5-fe-supervisor.conf
+    dest: /usr/local/etc/supervisor/conf.d/
+    owner: root
+    mode: 0644
+  notify: Supervisor restarted
+
 - name: 15Five frontend files generated and copied
   command: bash -lc "direnv exec /usr/local/src/fifteen5 /usr/local/bin/yarn && direnv exec /usr/local/src/fifteen5 /usr/local/bin/yarn build && direnv exec /usr/local/src/fifteen5 /usr/local/bin/python3.7 manage.py collectstatic --no-input"
   args:
     chdir: "/usr/local/src/fifteen5"
   tags:
     - deploy
+    - never
 
 - name: 15Five reset database
   command: bash -lc "RESET_DB=True direnv exec /usr/local/src/fifteen5 /usr/local/bin/python3.7 /usr/local/src/fifteen5/manage.py run_local_scripts && direnv exec /usr/local/src/fifteen5 /usr/local/bin/python3.7 /usr/local/src/fifteen5/manage.py clearsessions"
   tags:
     - db-refresh
+    - never

+ 12 - 1
ansible/roles/fifteen5/templates/envrc.j2

@@ -1,13 +1,24 @@
 export PYTHONPATH=`pwd`
 export PYTEST_ADDOPTS='-rs --durations=10 --reuse-db --isort --flake8'
 export DJANGO_SETTINGS_MODULE=ff.settings.dev.colin
-export FF_LOCAL_DOMAIN={{ansible_hostname}}.local
+export FF_LOCAL_DOMAIN=five.unbl.ink
 
 export FF_EXTRA_LOCAL_SCRIPTS_TO_RUN="
 ff.mods.report.company_templates.shackleton_expedition_company
 "
 
+export FF_LOG_FILE_PATH=/var/log/
 export FF_LOG_LEVEL=DEBUG
+export FF_LOG_SQL=False
+export FF_JSON_LOGGING=True
+export FF_BACKEND_SENTRY_DSN="https://ee742b3c0b2f451e8e0de99597a8ced0@sentry.unbl.ink/2"
+
+export FF_AWS_ACCESS_KEY_ID='minioadmin'
+export FF_AWS_SECRET_ACCESS_KEY='minioadmin'
+export FF_AWS_STORAGE_BUCKET_NAME_PUBLIC='fifteen5'
+export FF_AWS_STORAGE_BUCKET_NAME_PRIVATE='fifteen5'
+export FF_AWS_ENDPOINT_URL='http://minio.local:9000/'
+
 export FF_DB_NAME=fifteen5
 export FF_DB_USER=fifteenfive
 export FF_DB_PASSWORD={{fifteenfive_db_pass}}