1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-15 04:32:11 +00:00

Merge pull request #959 from tim-moody/mkiwix-lib

Add concurrency to iiab-make-kiwix-lib
This commit is contained in:
A Holt 2018-07-27 10:19:15 -04:00 committed by GitHub
commit c71c78003b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 10 deletions

View file

@ -1,8 +1,30 @@
#!/bin/bash
{{ systemctl_program }} stop kiwix-serve
/usr/bin/iiab-make-kiwix-lib.py
#/usr/bin/iiab-make-apache-config.py
{{ systemctl_program }} start kiwix-serve
exit 0
#!/bin/bash
LOCK_PATH=/run/lock/kiwix
mkdir -p $LOCK_PATH
WAITLOCK="$LOCK_PATH/make-kiwix-lib-wait.LCK";
RUNLOCK="$LOCK_PATH/kiwix-lib-access.LCK";
KIWIXLIB={{ kiwix_library_xml }}
exec 200>$WAITLOCK;
exec 201>$RUNLOCK;
if flock -n -e 200; then :
echo 'Waiting to run iiab-make-kiwix-lib.py'
# wait for up to 5 min
flock -x -w 300 201
flock -u 200 # unlock queue
echo "Now running iiab-make-kiwix-lib.py"
# write to {{ kiwix_library_xml }}.tmp to minimize kiwix down
# zim map could be out of sync for a few seconds
/usr/bin/iiab-make-kiwix-lib.py
{{ systemctl_program }} stop kiwix-serve
rm $KIWIXLIB
mv $KIWIXLIB.tmp $KIWIXLIB
{{ systemctl_program }} start kiwix-serve
else
echo "Can't get wait lock for iiab-make-kiwix-lib.py";
exit 1;
fi
exit 0

View file

@ -2,7 +2,7 @@
"""
Creates library.xml file for kiwix from contents of /zims/content and index
Creates temp library.xml file for kiwix from contents of /zims/content and index
Author: Tim Moody <tim(at)timmoody(dot)com>
Contributors: Jerry Vonau <jvonau3(at)gmail.com>
@ -30,6 +30,8 @@ iiab_config_file = "{{ iiab_config_file }}"
# Variables that should be read from config file
# All of these variables will be read from config files and recomputed in init()
iiab_zim_path = "{{ iiab_zim_path }}"
# Later we will append .tmp to file name
kiwix_library_xml = "{{ kiwix_library_xml }}"
iiab_base_path = "{{ iiab_base }}"
@ -41,8 +43,9 @@ old_zim_map = {"bad.zim" : "unparseable name"}
def main():
"""Server routine"""
global kiwix_library_xml
init()
kiwix_library_xml += '.tmp' # write to temp file
# remove existing file
try: