Fix kiwix plist to only include available ZIM archives

The LaunchAgent plist now dynamically includes only ZIM files that
actually exist in the kiwix directory, rather than all configured
archives. This prevents kiwix-serve from crashing when torrents are
still downloading.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Erich Blume 2026-01-14 13:17:55 -08:00
commit eb2f5b44cd
2 changed files with 14 additions and 2 deletions

View file

@ -158,6 +158,18 @@
- not item.stat.exists
notify: restart kiwix-serve
# --- Determine which archives are available ---
- name: Find available ZIM archives in kiwix directory
ansible.builtin.find:
paths: "{{ kiwix_zim_dir }}"
patterns: "*.zim"
file_type: any # includes symlinks
register: available_zim_files
- name: Build list of available archive filenames
ansible.builtin.set_fact:
kiwix_available_archives: "{{ available_zim_files.files | map(attribute='path') | map('basename') | list }}"
# --- LaunchAgent deployment ---
- name: Deploy kiwix-serve LaunchAgent plist
ansible.builtin.template:

View file

@ -11,8 +11,8 @@
<array>
<string>{{ kiwix_serve_bin }}</string>
<string>--port={{ kiwix_port }}</string>
{% for archive in kiwix_zim_archives %}
<string>{{ kiwix_zim_dir }}/{{ archive.filename }}</string>
{% for filename in kiwix_available_archives %}
<string>{{ kiwix_zim_dir }}/{{ filename }}</string>
{% endfor %}
</array>
<key>RunAtLoad</key>