Skip to content
Snippets Groups Projects
Verified Commit 4a4e5372 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Systemd services

parent e7913740
No related branches found
No related tags found
No related merge requests found
......@@ -16,3 +16,5 @@ funkwhale_api_ip: 127.0.0.1
funkwhale_api_port: 5000
funkwhale_settings_module: config.settings.production
funkwhale_env_vars: []
funkwhale_systemd_after: redis.service postgresql.service
funkwhale_systemd_service_name: funkwhale
---
# handlers file for funkwhale
- name: restart funkwhale
service:
name: funkwhale.target
state: restarted
......@@ -119,3 +119,13 @@ def test_migrations_applied(host):
"""
result = host.run(cmd)
assert result.stdout == "1"
@pytest.mark.parametrize(
"service",
["funkwhale-server", "funkwhale-worker", "funkwhale-beat", "funkwhale.target"],
)
def test_funkwhale_services(service, host):
service = host.service(service)
assert service.is_running
assert service.is_enabled
......@@ -55,6 +55,8 @@
mode: 0600
vars:
django_secret_key: "{{ secret_key['content'] | b64decode }}"
notify:
- restart funkwhale
- name: Download front-end files
become: true
......@@ -63,7 +65,8 @@
src: https://dev.funkwhale.audio/funkwhale/funkwhale/-/jobs/artifacts/{{ funkwhale_version }}/download?job=build_front
dest: "{{ funkwhale_install_path }}"
remote_src: true
notify:
- restart funkwhale
- name: Download api files
become: true
......@@ -72,6 +75,8 @@
src: https://dev.funkwhale.audio/funkwhale/funkwhale/-/jobs/artifacts/{{ funkwhale_version }}/download?job=build_api
dest: "{{ funkwhale_install_path }}"
remote_src: true
notify:
- restart funkwhale
- name: "Setup virtualenv"
become: true
......@@ -81,7 +86,6 @@
virtualenv: "{{ funkwhale_install_path }}/virtualenv"
virtualenv_python: python3
- name: "Install python dependencies"
become: true
become_user: "{{ funkwhale_username }}"
......@@ -89,7 +93,8 @@
requirements: "{{ funkwhale_install_path }}/api/requirements.txt"
virtualenv: "{{ funkwhale_install_path }}/virtualenv"
virtualenv_python: python3
notify:
- restart funkwhale
- name: "Collect static files"
command: "{{ funkwhale_install_path }}/virtualenv/bin/python api/manage.py collectstatic --no-input"
......@@ -98,7 +103,6 @@
args:
chdir: "{{ funkwhale_install_path }}"
- name: "Apply database migrations"
become: true
become_user: "{{ funkwhale_username }}"
......
---
# - include: packages.yml
# - include: db.yml
# - include: redis.yml
- include: packages.yml
- include: db.yml
- include: redis.yml
- include: funkwhale.yml
- include: services.yml
- include: nginx.yml
---
- name: "Create {{ funkwhale_systemd_service_name }}-* systemd file"
become: true
template:
src: "funkwhale-process.service"
dest: "/etc/systemd/system/{{ funkwhale_systemd_service_name }}-{{ item.name }}.service"
mode: 0600
with_items:
- name: worker
description: Funkwhale celery worker
command: "{{ funkwhale_install_path }}/virtualenv/bin/celery -A funkwhale_api.taskapp worker -l INFO"
- name: server
description: Funkwhale application server
command: "{{ funkwhale_install_path }}/virtualenv/bin/daphne -b ${FUNKWHALE_API_IP} -p ${FUNKWHALE_API_PORT} config.asgi:application --proxy-headers"
- name: beat
description: Funkwhale celery beat process
command: "{{ funkwhale_install_path }}/virtualenv/bin/celery -A funkwhale_api.taskapp beat -l INFO"
notify:
- restart funkwhale
- name: "Create {{ funkwhale_systemd_service_name }} systemd target file"
become: true
template:
src: "{{ funkwhale_systemd_service_name }}.target"
dest: "/etc/systemd/system/{{ funkwhale_systemd_service_name }}.target"
mode: 0600
notify:
- restart funkwhale
- name: "Start and enable {{ funkwhale_systemd_service_name }}-* services"
when: funkwhale_nginx_managed
systemd:
name: "{{ item }}"
enabled: true
daemon_reload: true
state: started
with_items:
- "{{ funkwhale_systemd_service_name }}.target"
- "{{ funkwhale_systemd_service_name }}-worker.service"
- "{{ funkwhale_systemd_service_name }}-server.service"
- "{{ funkwhale_systemd_service_name }}-beat.service"
{{ ansible_managed }}
# {{ ansible_managed }}
FUNKWHALE_HOSTNAME={{ funkwhale_hostname }}
FUNKWHALE_PROTOCOL={{ funkwhale_protocol }}
......
# {{ ansible_managed }}
[Unit]
Description={{ item.description }}
After={{ funkwhale_systemd_after }}
PartOf={{ funkwhale_systemd_service_name }}.target
[Service]
User={{ funkwhale_username }}
WorkingDirectory={{ funkwhale_install_path }}/api
EnvironmentFile={{ funkwhale_config_path }}/.env
ExecStart={{ item.command }}
[Install]
WantedBy=multi-user.target
[Unit]
Description=Funkwhale
Wants={{ funkwhale_systemd_service_name }}-server.service {{ funkwhale_systemd_service_name }}-worker.service {{ funkwhale_systemd_service_name }}-beat.service
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment