Bug 14466

Summary: is_zebra_running in koha-functions.sh is broken
Product: Koha Reporter: Mirko Tietgen <mirko>
Component: PackagingAssignee: Mirko Tietgen <mirko>
Status: RESOLVED DUPLICATE QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: mtompset, nick, robin
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 14466 -- is_zebra_running in koha-functions.sh is broken

Description Mirko Tietgen 2015-06-26 13:47:20 UTC
koha-start-zebra pbuilder
Starting Zebra server for pbuilder

build@vps181114:~$ ps aux | grep zebra
1002      6894  0.0  0.0  20000   552 ?        S    15:41   0:00 daemon --name=pbuilder-koha-zebra --pidfiles=/var/run/koha/pbuilder/ --errlog=/var/log/koha/pbuilder/zebra-error.log --stdout=/var/log/koha/pbuilder/zebra.log --output=/var/log/koha/pbuilder/zebra-output.log --verbose=1 --respawn --delay=30 --user=pbuilder-koha.pbuilder-koha -- zebrasrv -v none,fatal,warn -f /etc/koha/sites/pbuilder/koha-conf.xml
1002      6895  0.3  0.4 104320  4724 ?        S    15:41   0:00 zebrasrv -v none,fatal,warn -f /etc/koha/sites/pbuilder/koha-conf.xml


koha-stop-zebra pbuilder
Zebra already stopped for instance pbuilder.

ps aux | grep zebra
1002      6894  0.0  0.0  20000   552 ?        S    15:41   0:00 daemon --name=pbuilder-koha-zebra --pidfiles=/var/run/koha/pbuilder/ --errlog=/var/log/koha/pbuilder/zebra-error.log --stdout=/var/log/koha/pbuilder/zebra.log --output=/var/log/koha/pbuilder/zebra-output.log --verbose=1 --respawn --delay=30 --user=pbuilder-koha.pbuilder-koha -- zebrasrv -v none,fatal,warn -f /etc/koha/sites/pbuilder/koha-conf.xml
1002      6895  0.0  0.4 104320  4724 ?        S    15:41   0:00 zebrasrv -v none,fatal,warn -f /etc/koha/sites/pbuilder/koha-conf.xml
build     6944  0.0  0.0  11480   948 pts/0    S+   15:46   0:00 grep zebra
Comment 1 Mirko Tietgen 2015-06-26 13:51:20 UTC
This also has the effect that other commands do not work. If I disable and delete an instance, the user is still in use (running daemon and zebrasrv), can't be deleted, the dead conf symlink remains in /etc/apache2/sites-enabled, apache goes crazy over it and tells me to install stuff, zombie apocalypse starts and it all has to be cleaned up manually.
Comment 2 Mirko Tietgen 2015-06-28 11:53:17 UTC
Looks like the check is_zebra_running does not work.
Comment 3 Mirko Tietgen 2015-06-28 11:56:55 UTC
daemon --name="koha-koha-zebra" --user="koha-koha.koha-koha" --running

in the command line does not give me any feedback, regardless of the actual state. Should it?
Comment 4 Mirko Tietgen 2015-06-28 12:32:33 UTC
Created attachment 40705 [details] [review]
Bug 14466 -- is_zebra_running in koha-functions.sh is broken

is_zebra_running is broken, so koha-stop-zebra is broken too.
daemon needs the --pidfiles if given at start, and the --running
argumen has to be used before that.

Beware that the path to koha-functions.sh in the koha- scripts
is hardcoded for package installations (/usr/share…), so you need
to change it to match koha-functions.sh in your dev environment
to test this patch.

Test plan:

- Use koha-stop-zebra with an instance that has a running zebra.
It will tell you that zebra was already stopped.
- ps aux | grep zebra to see that is not true
- Apply patch. Modify koha-stop-zebra to use
  /your/devpath/debian/scripts/koha-functions.sh
- Use koha-stop-zebra. You will be told zebra is stopped now for
  your instance
- ps aux | grep zebra to verify it is gone
Comment 5 Mirko Tietgen 2015-06-28 12:37:49 UTC
Small addition to the test plan:

- Use koha-stop-zebra again. You will now (correctly) be told that zebra is already stopped for your instance.
Comment 6 Mirko Tietgen 2015-06-28 12:42:32 UTC
Would be nice if this could go into 3.18 too.
Comment 7 Mirko Tietgen 2015-06-28 12:49:06 UTC
(In reply to Mirko Tietgen from comment #3)
> daemon --name="koha-koha-zebra" --user="koha-koha.koha-koha" --running
> 
> in the command line does not give me any feedback, regardless of the actual
> state. Should it?

It does with --verbose, btw.
Comment 8 Mark Tompsett 2015-06-28 16:50:02 UTC
(In reply to Mirko Tietgen from comment #3)
> daemon --name="koha-koha-zebra" --user="koha-koha.koha-koha" --running
> 
> in the command line does not give me any feedback, regardless of the actual
> state. Should it?

Perhaps check "echo $?" (without the double quotes)?
Comment 9 Mark Tompsett 2015-06-28 17:33:35 UTC
(In reply to Mirko Tietgen from comment #0)
> ps aux | grep zebra
> 1002      6894  0.0  0.0  20000   552 ?        S    15:41   0:00 daemon
> --name=pbuilder-koha-zebra --pidfiles=/var/run/koha/pbuilder/
> --errlog=/var/log/koha/pbuilder/zebra-error.log
> --stdout=/var/log/koha/pbuilder/zebra.log
> --output=/var/log/koha/pbuilder/zebra-output.log --verbose=1 --respawn
> --delay=30 --user=pbuilder-koha.pbuilder-koha -- zebrasrv -v none,fatal,warn
> -f /etc/koha/sites/pbuilder/koha-conf.xml
> 1002      6895  0.0  0.4 104320  4724 ?        S    15:41   0:00 zebrasrv -v
> none,fatal,warn -f /etc/koha/sites/pbuilder/koha-conf.xml
> build     6944  0.0  0.0  11480   948 pts/0    S+   15:46   0:00 grep zebra

When did --pidfiles get added? It's not in 3.14.x or 3.16.x as far as I know.
Comment 10 Mirko Tietgen 2015-06-28 19:55:26 UTC

*** This bug has been marked as a duplicate of bug 14361 ***