Bugzilla – Attachment 41168 Details for
Bug 14448
Hypnotoad and Nginx config for REST API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14448 - Adding the REST API as a Hypnotoad service, koha-api-daemon.
Bug-14448---Adding-the-REST-API-as-a-Hypnotoad-ser.patch (text/plain), 5.06 KB, created by
Olli-Antti Kivilahti
on 2015-07-24 14:09:46 UTC
(
hide
)
Description:
Bug 14448 - Adding the REST API as a Hypnotoad service, koha-api-daemon.
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2015-07-24 14:09:46 UTC
Size:
5.06 KB
patch
obsolete
>From 6de9fe54de15382e802d6ad96ab29b3738bea597 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Thu, 11 Jun 2015 17:36:14 +0300 >Subject: [PATCH] Bug 14448 - Adding the REST API as a Hypnotoad service, > koha-api-daemon. > >After running make, the koha-api-daemon.sh -script should be in >../koha-dev/bin/koha-api-daemon.sh > >Link it to the init-directory and set up upstart triggers: >..$ ln -s /home/koha/koha-dev/bin/koha-api-daemon.sh /etc/init.d/koha-api-daemon >..$ update-rc.d koha-api-daemon defaults > >Start hypnotoad: >..$ service koha-api-daemon start > >Hypnotoad is now listening in 127.0.0.1:8080 and is preconfigured to be production ready. > >Hypnotoad config is in $KOHA_PATH/api/v1/hypnotoad.conf > >For more info, read the koha-api-daemon.sh -service >--- > api/v1/hypnotoad.conf | 39 +++++++++++++++++++++++ > misc/bin/koha-api-daemon.sh | 78 +++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 117 insertions(+) > create mode 100644 api/v1/hypnotoad.conf > create mode 100755 misc/bin/koha-api-daemon.sh > >diff --git a/api/v1/hypnotoad.conf b/api/v1/hypnotoad.conf >new file mode 100644 >index 0000000..9e2f0d8 >--- /dev/null >+++ b/api/v1/hypnotoad.conf >@@ -0,0 +1,39 @@ >+### Configuration options for the hypnotoad server >+## See. https://metacpan.org/pod/Mojo::Server::Hypnotoad >+# >+# Setting timeouts to rather large values since some requests, like show all borrowers (120 000 here) >+# take a LOT of time. >+{ >+ hypnotoad => { >+ proxy => 1, >+ >+ #Number of worker processes >+ workers => 1, >+ >+ #When REST API client errors happen, where to redirect for API specification? >+ swagger2DocumentationUrl => "https://10.0.3.12:444/v1/doc/", >+ >+ #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, >+ >+ #Maximum amount of time in seconds a connection can be inactive before getting closed. >+ inactivity_timeout => 120, >+ >+ #Heartbeat interval in seconds >+ heartbeat_interval => 10, >+ >+ #Maximum amount of time in seconds before a worker without a heartbeat will be stopped gracefully >+ heartbeat_timeout => 120, >+ >+ #Which address:port to listen to, hypnotoad defaults to ['http://*:8080'] >+ listen => ['http://*:8081'], >+ } >+}; >diff --git a/misc/bin/koha-api-daemon.sh b/misc/bin/koha-api-daemon.sh >new file mode 100755 >index 0000000..4d46603 >--- /dev/null >+++ b/misc/bin/koha-api-daemon.sh >@@ -0,0 +1,78 @@ >+#!/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 <http://www.gnu.org/licenses>. >+ >+### 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=kivilahtio >+loggedInUser=`whoami` >+NAME=koha-api-daemon >+KOHA_PATH=/home/koha/kohaclone/ >+## See Koha/REST/V1.pm for more info about the environmental variables. >+export MOJO_CONFIG=$KOHA_PATH/api/v1/hypnotoad.conf >+#You get 3 logfiles here, .log, .stderr, .stdout >+export MOJO_LOGFILES=/home/koha/koha-dev/var/log/kohaapi.mojo >+export MOJO_LOGLEVEL=debug >+ >+##ABOUT CHANGING THE process name/command visible by programs like 'top' and 'ps'. >+# >+# You can make a small incision to /usr/local/share/perl/5.14.2/Mojo/Server.pm or wherever your >+# Mojo::Server is located at. >+# Go to load_app(), and after perl code line >+# 60: FindBin->again; >+# add >+# $0 = 'koha-api-daemon'; >+# This renames all hypnotoad processes as koha-api-daemon. >+# No side-effects encoutered so far but minimal testing here! >+ >+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" >+ su -c "hypnotoad $KOHA_PATH/api/v1/script.cgi" $USER >+ echo "ALL GLORY TO THE HYPNOTOAD." >+} >+function stop { >+ su -c "hypnotoad $KOHA_PATH/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 >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14448
:
40548
|
40549
|
40550
|
41168
|
41169
|
41333
|
41334
|
41545
|
41546