1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

fixes after testing

This commit is contained in:
tim-moody 2018-07-23 15:18:31 -04:00
parent 051f5387dc
commit 6c88827fe6
2 changed files with 36 additions and 28 deletions

View file

@ -1,25 +1,30 @@
#!/bin/bash #!/bin/bash
LOCK_PATH=/run/lock/kiwix LOCK_PATH=/run/lock/kiwix
WAITLOCK="$LOCK_PATH/make-kiwix-lib-wait.LCK"; mkdir -p $LOCK_PATH
RUNLOCK=WAITLOCK="$LOCK_PATH/make-kiwix-lib-run.LCK";
exec 200>$WAITLOCK; WAITLOCK="$LOCK_PATH/make-kiwix-lib-wait.LCK";
exec 201>$RUNLOCK; RUNLOCK="$LOCK_PATH/kiwix-lib-access.LCK";
KIWIXLIB={{ kiwix_library_xml }}
if flock -n -e 200; then :
echo 'Waiting to run iiab-make-kiwix-lib.py' exec 200>$WAITLOCK;
# wait for up to 5 min exec 201>$RUNLOCK;
flock -x -w 300 201
echo "Now running iiab-make-kiwix-lib.py" if flock -n -e 200; then :
# write to {{ kiwix_library_xml }}.tmp to minimize kiwix down echo 'Waiting to run iiab-make-kiwix-lib.py'
# zim map could be out of sync for a few seconds # wait for up to 5 min
/usr/bin/iiab-make-kiwix-lib.py flock -x -w 300 201
{{ systemctl_program }} stop kiwix-serve flock -u 200 # unlock queue
rm {{ kiwix_library_xml }} echo "Now running iiab-make-kiwix-lib.py"
mv {{ kiwix_library_xml }}.tmp {{ kiwix_library_xml }} # write to {{ kiwix_library_xml }}.tmp to minimize kiwix down
{{ systemctl_program }} start kiwix-serve # zim map could be out of sync for a few seconds
else /usr/bin/iiab-make-kiwix-lib.py
echo "Can't get wait lock for iiab-make-kiwix-lib.py"; {{ systemctl_program }} stop kiwix-serve
exit 1; rm $KIWIXLIB
fi mv $KIWIXLIB.tmp $KIWIXLIB
exit 0 {{ 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> Author: Tim Moody <tim(at)timmoody(dot)com>
Contributors: Jerry Vonau <jvonau3(at)gmail.com> Contributors: Jerry Vonau <jvonau3(at)gmail.com>
@ -30,7 +30,9 @@ iiab_config_file = "{{ iiab_config_file }}"
# Variables that should be read from config file # Variables that should be read from config file
# All of these variables will be read from config files and recomputed in init() # All of these variables will be read from config files and recomputed in init()
iiab_zim_path = "{{ iiab_zim_path }}" iiab_zim_path = "{{ iiab_zim_path }}"
kiwix_library_xml = "{{ kiwix_library_xml }}.tmp"
# Later we will append .tmp to file name
kiwix_library_xml = "{{ kiwix_library_xml }}"
iiab_base_path = "{{ iiab_base }}" iiab_base_path = "{{ iiab_base }}"
kiwix_manage = iiab_base_path + "/kiwix/bin/kiwix-manage" kiwix_manage = iiab_base_path + "/kiwix/bin/kiwix-manage"
@ -41,8 +43,9 @@ old_zim_map = {"bad.zim" : "unparseable name"}
def main(): def main():
"""Server routine""" """Server routine"""
global kiwix_library_xml
init() init()
kiwix_library_xml += '.tmp' # write to temp file
# remove existing file # remove existing file
try: try: