1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-14 20:22:08 +00:00

add systemd service and add task to compile translations

This commit is contained in:
rgangela99 2018-07-28 13:24:12 -04:00 committed by Aidan Fitzgerald
parent 4681099cba
commit 83e6627861
4 changed files with 55 additions and 13 deletions

View file

@ -14,7 +14,7 @@ lokole_enabled: True
lokole_url: /lokole
lokole_full_url: "http://{{ iiab_hostname }}.{{ iiab_domain }}/{{ lokole_url }}"
lokole_domain_socket: "{{ lokole_install_path }}/lokole_gunicorn.sock"
lokole_domain_socket: "{{ lokole_run_directory }}/lokole_gunicorn.sock"
# Global variables provided by setup-lokole.sh L157-166
# https://github.com/ascoderu/opwen-webapp/blob/master/setup/setup-lokole.sh#L157

View file

@ -22,11 +22,22 @@
tags:
- install
when: internet_available
- name: Compile translations
shell: |
python_version=$(python3 -c 'from sys import version_info; print("%s.%s" % (version_info.major, version_info.minor));';)
{{ lokole_venv }}/bin/pybabel compile -d {{ item }}/translations
with_items:
- "{{ lokole_venv }}/lib/python${python_version}/site-packages/opwen_email_client/webapp"
tags:
- install
- name: Create run directory
file:
path: "{{ lokole_run_directory }}"
state: directory
tags:
- configure
- name: Configure Lokole
template:
@ -39,10 +50,31 @@
template:
src: webapp.sh.j2
dest: "{{ lokole_run_directory }}/webapp.sh"
mode: a+x
tags:
- configure
- name: Create 'lokole' service
template:
src: lokole.service.j2
dest: "/etc/systemd/system/lokole.service"
tags:
- systemd
- name: Enable 'lokole' service
systemd:
daemon_reload: yes
name: lokole
enabled: yes
state: restarted
when: lokole_enabled
- name: Disable 'lokole' service
systemd:
name: lokole
enabled: no
state: stopped
when: not lokole_enabled
# Everything below this line is unused
@ -53,7 +85,7 @@
- name: Enable httpd conf file if we are disabled (debuntu)
file:
src: /etc/apache2/sites-available/lokole.conf
src: /etc/{{ apache_config_dir }}/lokole.conf
dest: /etc/apache2/sites-enabled/lokole.conf
state: link
when: lokole_enabled and is_debuntu
@ -80,14 +112,8 @@
value: lokole
- option: description
value: '"lokole is an email service."'
- option: lokole_src
value: "{{ lokole_src }}"
- option: lokole_abs_path
value: "{{ lokole_abs_path }}"
- option: lokole_db_name
value: "{{ lokole_db_name }}"
- option: lokole_db_user
value: "{{ lokole_db_user }}"
- option: lokole_run_directory
value: "{{ lokole_run_directory }}"
- option: lokole_url
value: "{{ lokole_url }}"
- option: lokole_full_url

View file

@ -0,0 +1,16 @@
[Unit]
Description=Provides the Lokole Server
#Requires=lokole.socket
After=network.target
[Service]
Type=simple
ExecStart=/bin/bash {{ lokole_run_directory }}/webapp.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
User=root
Group=root
PrivateTmp=true
[Install]
WantedBy=multi-user.target

View file

@ -1,9 +1,9 @@
#!/usr/bin/env sh
. '${opwen_webapp_envs}'
. '{{lokole_run_directory}}/webapp_secrets.sh'
'{{lokole_venv}}/bin/gunicorn' \
--timeout='300' \
--workers='{{ [4, ansible_memtotal_mb / 200] | min | int }}' \
--bind='unix:{{lokole_domain_socket}}' \
--bind='unix:{{ lokole_domain_socket }}' \
--log-level='error' \
'opwen_email_client.webapp:app'