Bug 10624 - koha-common.init should implement the 'status' option switch
Summary: koha-common.init should implement the 'status' option switch
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Packaging (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Testopia
URL:
Keywords:
Depends on: 10617 10622
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-22 17:33 UTC by Tomás Cohen Arazi
Modified: 2014-05-26 21:04 UTC (History)
3 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 10624: 'status' option switch for the packages init script (3.18 KB, patch)
2013-08-30 16:25 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Rebased. (3.19 KB, patch)
2013-09-19 14:27 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Added the PID parameter to daemon as it failed to check SIP servers were running otherwise. (3.34 KB, patch)
2013-09-27 14:37 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 10624: 'status' option switch for the packages init script (3.39 KB, patch)
2013-10-02 01:01 UTC, Robin Sheat
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi 2013-07-22 17:33:59 UTC
There's a status option on the script that is currently commented out.
An implementation of it is needed. Trying to capture what Robin said on IRC, it should:
- Know what should be running
- Check if everything is running correctly
- Return a warning otherwise
Comment 1 Tomás Cohen Arazi 2013-08-30 16:25:42 UTC Comment hidden (obsolete)
Comment 2 Robin Sheat 2013-09-19 04:48:45 UTC
I think there's something confusing git going on here. I apply 10617 and 10622 and end up with a result that's different to what the patch says it should be. It might just be a matter of rebasing against current master.

My patch ends up with:

-# TODO: Implement this. It should check every daemon is running
-#  status)
-#        status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
-#        ;;
-  *)
-    #echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
-    echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
-       exit 3
-       ;;
+        ;;
+    esac
+    ;;
+esac
+    ;;
+esac
+    ;a_status
+  ;a_status
+status
+atus
+status  *)
+
+status  *)
+age: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
+    exit 3
+    ;;
 esac
 
 :
Comment 3 Tomás Cohen Arazi 2013-09-19 14:27:28 UTC Comment hidden (obsolete)
Comment 4 Robin Sheat 2013-09-19 23:55:46 UTC
This doesn't seem to work for me, and I can't immediately tell why:

$ sudo koha-start-sip test
Starting SIP server for test
$ sudo ./koha-common.init status
Zebra server running for instace test:.
SIP server running for instace test: failed!
$ ps ax|grep -i sip
32410 ?        S      0:00 daemon --name=test-koha-sip --errlog=/var/log/koha/test/sip-error.log --stdout=/var/log/koha/test/sip.log --output=/var/log/koha/test/sip-output.log --verbose=1 --respawn --delay=30 --pidfiles=/var/run/koha/test --user=test-koha.test-koha -- perl /usr/share/koha/lib/C4/SIP/SIPServer.pm /etc/koha/sites/test/SIPconfig.xml
32411 ?        S      0:00 perl /usr/share/koha/lib/C4/SIP/SIPServer.pm /etc/koha/sites/test/SIPconfig.xml
32412 ?        S      0:00 perl /usr/share/koha/lib/C4/SIP/SIPServer.pm /etc/koha/sites/test/SIPconfig.xml

any ideas?
Comment 5 I'm just a bot 2013-09-24 05:43:54 UTC
Patch applied cleanly, go forth and signoff
Comment 6 Tomás Cohen Arazi 2013-09-27 14:37:49 UTC Comment hidden (obsolete)
Comment 7 Robin Sheat 2013-10-02 00:59:33 UTC
$ sudo ./koha-common.init status
Zebra server running for instace test:.
SIP server running for instace test:.
$ sudo kill  2170 2171 2179
$ sudo ./koha-common.init status
Zebra server running for instace test:.
SIP server running for instace test: failed!

looks good. One note is that if you forget to use sudo, the error message is pretty obscure. We should probably fail cleaner. But that's not the fault of this.
Comment 8 Robin Sheat 2013-10-02 01:01:19 UTC
Created attachment 21706 [details] [review]
Bug 10624: 'status' option switch for the packages init script

This patch makes the init script return the status of the relevant processes.
It relies on the koha-list switches added by 10622, and is written on top of the patch from 10617 that cleaned the init script.

To test:
- Apply the patch (+ 10622 so the SIP part works), build package and install
- Run
 $ service koha-common status

Note: it can be tested just copying the debian/koha-common.init script to a server running koha-common instances and calling it
 $ ./koha-common.init status

If you don't have a patched koha-list command it will fail to report SIP servers status.

Regards
To+

Edit: added the PID parameter to daemon as it failed to check SIP servers were running otherwise.

Sponsored-by: Universidad Nacional de Cordoba
Signed-off-by: Robin Sheat <robin@catalyst.net.nz>
Comment 9 Galen Charlton 2013-10-09 04:56:06 UTC
Pushed to master.  Thanks, Tomás!
Comment 10 Tomás Cohen Arazi 2013-11-19 18:03:42 UTC
This patch has been pushed to 3.12.x, will be in 3.12.7.