Bug 17376 - rebuild_zebra.pl in daemon mode no database access kills the process
authorFridolin Somers <fridolin.somers@biblibre.com>
Thu, 29 Sep 2016 14:19:48 +0000 (16:19 +0200)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 28 Oct 2016 11:28:37 +0000 (11:28 +0000)
commitbfcc7cad70bfc23163865b2ff39eb592d6d9d152
treed5a9cdec631d2581c72f89e6bb235e0a964bc958
parent2d4226902d20bc0d3bcd696f34d56ac60ee2c5b6
Bug 17376 - rebuild_zebra.pl in daemon mode no database access kills the process

When running rebuild_zebra.pl in daemon mode, a while loop runs the script for ever.
But if something crashes inside the rebuild process, the all daemon crashes.
For example when it can not access database.
This problem may be temporary so daemon should keep running.

This patch add eval around the rebuild process to allow a run to fail without killing the daemon.
Also moves the DB handler get inside daemon loop because it is broken is DB stoppes.

This is a big issue for indexer running in a systemd service.

Test plan :
- run rebuild_zebra.pl in daemon mode :
/home/koha/src/misc/migration_tools/rebuild_zebra.pl -daemon -z -a -b -x --sleep 30
- stop the database
- wait a minute
=> you see an error on database connexion
=> the daemon is still running
- restart the database
- test the indexer by creating a new record (wait for a minute)

Signed-off-by: Jacek Ablewicz <abl@biblos.pk.edu.pl>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
misc/migration_tools/rebuild_zebra.pl