View | Details | Raw Unified | Return to bug 13799
Collapse All | Expand All

(-)a/api/v1/hypnotoad.conf (+33 lines)
Line 0 Link Here
1
### Configuration options for the hypnotoad server
2
## See. https://metacpan.org/pod/Mojo::Server::Hypnotoad
3
#
4
# Setting timeouts to rather large values since some requests, like show all borrowers (120 000 here)
5
# take a LOT of time.
6
{
7
  hypnotoad => {
8
    proxy => 1,
9
10
    #Number of worker processes
11
    workers => 1,
12
13
    #Maximum number of connections a worker is allowed to accept before stopping
14
    #gracefully and then getting replaced with a newly started worker
15
    accepts => 100,
16
17
    #Maximum number of concurrent connections each worker process is allowed to
18
    #handle before stopping to accept new incoming connections
19
    clients => 5,
20
21
    #Number of keep-alive requests per connection
22
    requests => 50,
23
24
    #Maximum amount of time in seconds a connection can be inactive before getting closed.
25
    inactivity_timeout => 120,
26
27
    #Heartbeat interval in seconds
28
    heartbeat_interval => 10,
29
30
    #Maximum amount of time in seconds before a worker without a heartbeat will be stopped gracefully
31
    heartbeat_timeout => 120,
32
  }
33
};
(-)a/misc/bin/koha-api-daemon.sh (-1 / +78 lines)
Line 0 Link Here
0
- 
1
#!/bin/bash
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
### BEGIN INIT INFO
19
# Provides:          koha-api-daemon
20
# Required-Start:    $syslog $remote_fs
21
# Required-Stop:     $syslog $remote_fs
22
# Default-Start:     2 3 4 5
23
# Default-Stop:      0 1 6
24
# Short-Description: Hypnotoad Mojolicious Server for handling Koha API requests
25
### END INIT INFO
26
27
USER=kivilahtio
28
loggedInUser=`whoami`
29
NAME=koha-api-daemon
30
KOHA_PATH=/home/koha/kohaclone/
31
32
## See Koha/REST/V1.pm for more info about the environmental variables.
33
export MOJO_CONFIG=$KOHA_PATH/api/v1/hypnotoad.conf
34
export MOJO_LOGFILE=/home/koha/koha-dev/var/log/kohaapi.mojo.log
35
export MOJO_LOGLEVEL=debug
36
37
##ABOUT CHANGING THE process name/command visible by programs like 'top' and 'ps'.
38
#
39
# You can make a small incision to /usr/local/share/perl/5.14.2/Mojo/Server.pm or wherever your
40
# Mojo::Server is located at.
41
# Go to load_app(), and after perl code line
42
# 60: FindBin->again;
43
# add
44
# $0 = 'koha-api-daemon';
45
# This renames all hypnotoad processes as koha-api-daemon.
46
# No side-effects encoutered so far but minimal testing here!
47
48
if [[ $EUID -ne 0 && $loggedInUser -ne $USER ]]; then
49
    echo "You must run this script as 'root' or as '$USER'";
50
    exit 1;
51
fi
52
53
function start {
54
    echo "Starting Hypnotoad"
55
    su -c "hypnotoad $KOHA_PATH/api/v1/script.cgi" $USER
56
    echo "ALL GLORY TO THE HYPNOTOAD."
57
}
58
function stop {
59
    su -c "hypnotoad $KOHA_PATH/api/v1/script.cgi -s" $USER
60
}
61
62
case "$1" in
63
    start)
64
        start
65
      ;;
66
    stop)
67
        stop
68
      ;;
69
    restart)
70
        echo "Restarting Hypnotoad"
71
        stop
72
        start
73
      ;;
74
    *)
75
      echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
76
      exit 1
77
      ;;
78
esac

Return to bug 13799