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:
parent
3847c12b42
commit
eb2f5b44cd
2 changed files with 14 additions and 2 deletions
|
|
@ -158,6 +158,18 @@
|
||||||
- not item.stat.exists
|
- not item.stat.exists
|
||||||
notify: restart kiwix-serve
|
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 ---
|
# --- LaunchAgent deployment ---
|
||||||
- name: Deploy kiwix-serve LaunchAgent plist
|
- name: Deploy kiwix-serve LaunchAgent plist
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@
|
||||||
<array>
|
<array>
|
||||||
<string>{{ kiwix_serve_bin }}</string>
|
<string>{{ kiwix_serve_bin }}</string>
|
||||||
<string>--port={{ kiwix_port }}</string>
|
<string>--port={{ kiwix_port }}</string>
|
||||||
{% for archive in kiwix_zim_archives %}
|
{% for filename in kiwix_available_archives %}
|
||||||
<string>{{ kiwix_zim_dir }}/{{ archive.filename }}</string>
|
<string>{{ kiwix_zim_dir }}/{{ filename }}</string>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</array>
|
</array>
|
||||||
<key>RunAtLoad</key>
|
<key>RunAtLoad</key>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue