Bugzilla – Attachment 40099 Details for
Bug 13799
Add base for building RESTful API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13799 - Adding the REST API as a Hypnotoad service, koha-api-daemon.
Bug-13799---Adding-the-REST-API-as-a-Hypnotoad-ser.patch (text/plain), 4.76 KB, created by
Olli-Antti Kivilahti
on 2015-06-12 10:01:55 UTC
(
hide
)
Description:
Bug 13799 - Adding the REST API as a Hypnotoad service, koha-api-daemon.
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2015-06-12 10:01:55 UTC
Size:
4.76 KB
patch
obsolete
>From 9b89c29e2d3cdde5a129f82057d196cc0272f10c 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 13799 - 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 | 33 ++++++++++++++++++ > misc/bin/koha-api-daemon.sh | 78 +++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 111 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..7cdfcd1 >--- /dev/null >+++ b/api/v1/hypnotoad.conf >@@ -0,0 +1,33 @@ >+### 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, >+ >+ #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, >+ } >+}; >diff --git a/misc/bin/koha-api-daemon.sh b/misc/bin/koha-api-daemon.sh >new file mode 100755 >index 0000000..acbc08e >--- /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 >+export MOJO_LOGFILE=/home/koha/koha-dev/var/log/kohaapi.mojo.log >+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.7.9.5
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 13799
:
36700
|
36705
|
36938
|
36941
|
37119
|
37132
|
37172
|
38246
|
39156
|
39158
|
39159
|
39160
|
39161
|
39162
|
39163
|
39164
|
40088
|
40092
|
40093
|
40094
|
40098
|
40099
|
40101
|
40140
|
40141
|
40142
|
40463
|
40464
|
40465
|
40466
|
40467
|
40468
|
40469
|
40470
|
40471
|
40551
|
40552
|
40553
|
40554
|
40560
|
40561
|
40584
|
40585
|
40586
|
40587
|
40616
|
40617
|
40618
|
40619
|
41160
|
41161
|
41162
|
41268
|
41269
|
41270
|
41271
|
41272
|
41273
|
41274
|
41320
|
41321
|
41326
|
41327
|
41328
|
41329
|
41330
|
41331
|
41538
|
41539
|
41540
|
41541
|
41542
|
41543
|
41547
|
41554
|
42044
|
42085
|
42086
|
42123
|
42518
|
42766
|
42768
|
42801
|
42874
|
42875
|
42876
|
42877
|
42878
|
43186
|
43187
|
43189
|
43190
|
43191
|
43192
|
43204
|
43205
|
43206
|
43207
|
43208
|
43209
|
43210
|
43211
|
43212
|
43213
|
43214
|
43980
|
43981
|
43987
|
43989
|
43990
|
43991
|
43992
|
43993
|
43994
|
43995
|
43996
|
43997
|
43998
|
43999
|
44000
|
44001
|
44185
|
44285
|
44313
|
44375
|
44376
|
44377
|
44378
|
44379
|
44380
|
44381
|
44382
|
44383
|
44384
|
44385