@@ -, +, @@ koha-api-daemon. --- api/v1/hypnotoad.conf | 21 ++++++++++++++ misc/bin/koha-api-daemon.sh | 66 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 api/v1/hypnotoad.conf create mode 100755 misc/bin/koha-api-daemon.sh --- a/api/v1/hypnotoad.conf +++ a/api/v1/hypnotoad.conf @@ -0,0 +1,21 @@ +### Configuration options for the hypnotoad server +## See. https://metacpan.org/pod/Mojo::Server::Hypnotoad +{ + hypnotoad => { + proxy => 1, + + #Number of worker processes + workers => 4, + + #Maximum number of connections a worker is allowed to accept before stopping + #gracefully and then getting replaced with a newly started worker + accepts => 100, + + #Maximum number of concurrent connections each worker process is allowed to + #handle before stopping to accept new incoming connections + clients => 5, + + #Number of keep-alive requests per connection + requests => 50, + } +}; --- a/misc/bin/koha-api-daemon.sh +++ a/misc/bin/koha-api-daemon.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +### BEGIN INIT INFO +# Provides: koha-api-daemon +# Required-Start: $syslog $remote_fs +# Required-Stop: $syslog $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Hypnotoad Mojolicious Server for handling Koha API requests +### END INIT INFO + +USER=__KOHA_USER__ +loggedInUser=`whoami` +NAME=koha-api-daemon +KOHA_PATH=__INTRANET_WWW_DIR__ + +test -f $ZEBRASRV || exit 0 + +OTHERUSER='' +if [[ $EUID -ne 0 && $loggedInUser -ne $USER ]]; then + echo "You must run this script as 'root' or as '$USER'"; + exit 1; +fi + +function start { + echo "Starting Hypnotoad" + echo "ALL GLORY TO THE HYPNOTOAD." + su -c "hypnotoad $PERL5LIB/api/v1/script.cgi" $USER +} +function stop { + echo "Stopping Hypnotoad" + su -c "hypnotoad $PERL5LIB/api/v1/script.cgi -s" $USER +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + echo "Restarting Hypnotoad" + stop + start + ;; + *) + echo "Usage: /etc/init.d/$NAME {start|stop|restart}" + exit 1 + ;; +esac --