Bug 13791 - Plack - Out of the box support on packages
Summary: Plack - Out of the box support on packages
Status: Pushed to Master
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low new feature
Assignee: Tomás Cohen Arazi
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
Depends on: 13793 13805 13815 14743
Blocks: 17429 14706 14775 14938
  Show dependency treegraph
 
Reported: 2015-03-04 10:09 UTC by Dobrica Pavlinusic
Modified: 2016-10-11 16:38 UTC (History)
9 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 13791: Plack out-of-the-box support on packages (11.40 KB, patch)
2015-08-13 17:58 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: Apache configuration files (3.21 KB, patch)
2015-08-13 17:58 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: koha-plack documentation (3.54 KB, patch)
2015-08-13 17:58 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: make koha-list aware of plack (3.38 KB, patch)
2015-08-13 17:58 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: make koha-common init script aware of plack (1.64 KB, patch)
2015-08-13 17:58 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: make koha-list aware of plack (3.38 KB, patch)
2015-08-13 18:29 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: Plack out-of-the-box support on packages (12.46 KB, patch)
2015-08-14 19:15 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: Apache configuration files (4.42 KB, patch)
2015-08-14 19:15 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: koha-plack documentation (3.54 KB, patch)
2015-08-14 19:15 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: make koha-list aware of plack (5.70 KB, patch)
2015-08-14 19:15 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: make koha-common init script aware of plack (4.02 KB, patch)
2015-08-14 19:16 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: Plack out-of-the-box support on packages (13.35 KB, patch)
2015-08-14 21:44 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: Apache configuration files (4.41 KB, patch)
2015-08-14 21:44 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: koha-plack documentation (3.54 KB, patch)
2015-08-14 21:44 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: make koha-list aware of plack (5.70 KB, patch)
2015-08-14 21:45 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: make koha-common init script aware of plack (4.35 KB, patch)
2015-08-14 21:45 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: tab-completion for koha-plack in bash (3.75 KB, patch)
2015-08-14 21:45 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: Plack out-of-the-box support on packages (13.44 KB, patch)
2015-08-17 13:46 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: Apache configuration files (4.41 KB, patch)
2015-08-17 13:46 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: koha-plack documentation (3.54 KB, patch)
2015-08-17 13:46 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: make koha-list aware of plack (5.70 KB, patch)
2015-08-17 13:46 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: make koha-common init script aware of plack (4.35 KB, patch)
2015-08-17 13:46 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: tab-completion for koha-plack in bash (3.75 KB, patch)
2015-08-17 13:46 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: Plack out-of-the-box support on packages (13.49 KB, patch)
2015-08-18 08:02 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 13791: Apache configuration files (4.46 KB, patch)
2015-08-18 08:02 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 13791: koha-plack documentation (3.60 KB, patch)
2015-08-18 08:02 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 13791: make koha-list aware of plack (5.75 KB, patch)
2015-08-18 08:02 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 13791: make koha-common init script aware of plack (4.40 KB, patch)
2015-08-18 08:02 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 13791: tab-completion for koha-plack in bash (3.81 KB, patch)
2015-08-18 08:02 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 13791: Plack out-of-the-box support on packages (13.57 KB, patch)
2015-08-21 08:36 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 13791: Apache configuration files (4.54 KB, patch)
2015-08-21 08:36 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 13791: koha-plack documentation (3.67 KB, patch)
2015-08-21 08:36 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 13791: make koha-list aware of plack (5.83 KB, patch)
2015-08-21 08:36 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 13791: make koha-common init script aware of plack (4.48 KB, patch)
2015-08-21 08:36 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 13791: tab-completion for koha-plack in bash (3.88 KB, patch)
2015-08-21 08:36 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 13791: (QA followup) Plack support requires Apache 2.4.8+ (1.81 KB, patch)
2015-08-24 16:13 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13791: (RM followup) Add new dependencies for packaging (4.98 KB, patch)
2015-08-27 16:19 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Dobrica Pavlinusic 2015-03-04 10:09:25 UTC
Offer plack as valid alternative for installation.

For now, some progress is documented at wiki page:

http://wiki.koha-community.org/wiki/Plack
Comment 1 Tomás Cohen Arazi 2015-08-13 17:58:05 UTC Comment hidden (obsolete)
Comment 2 Tomás Cohen Arazi 2015-08-13 17:58:09 UTC Comment hidden (obsolete)
Comment 3 Tomás Cohen Arazi 2015-08-13 17:58:13 UTC Comment hidden (obsolete)
Comment 4 Tomás Cohen Arazi 2015-08-13 17:58:16 UTC Comment hidden (obsolete)
Comment 5 Tomás Cohen Arazi 2015-08-13 17:58:20 UTC Comment hidden (obsolete)
Comment 6 Tomás Cohen Arazi 2015-08-13 18:29:42 UTC Comment hidden (obsolete)
Comment 7 Tomás Cohen Arazi 2015-08-14 19:15:27 UTC Comment hidden (obsolete)
Comment 8 Tomás Cohen Arazi 2015-08-14 19:15:35 UTC Comment hidden (obsolete)
Comment 9 Tomás Cohen Arazi 2015-08-14 19:15:42 UTC Comment hidden (obsolete)
Comment 10 Tomás Cohen Arazi 2015-08-14 19:15:52 UTC Comment hidden (obsolete)
Comment 11 Tomás Cohen Arazi 2015-08-14 19:16:03 UTC Comment hidden (obsolete)
Comment 12 Tomás Cohen Arazi 2015-08-14 21:44:44 UTC Comment hidden (obsolete)
Comment 13 Tomás Cohen Arazi 2015-08-14 21:44:51 UTC Comment hidden (obsolete)
Comment 14 Tomás Cohen Arazi 2015-08-14 21:44:59 UTC Comment hidden (obsolete)
Comment 15 Tomás Cohen Arazi 2015-08-14 21:45:07 UTC Comment hidden (obsolete)
Comment 16 Tomás Cohen Arazi 2015-08-14 21:45:17 UTC Comment hidden (obsolete)
Comment 17 Tomás Cohen Arazi 2015-08-14 21:45:26 UTC Comment hidden (obsolete)
Comment 18 Josef Moravec 2015-08-17 05:48:37 UTC
Hello Tomás, 
I think there is a typo in apache configuration here:
http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=41509&action=diff#a/debian/templates/apache-site.conf.in_sec1

Start tag <IfVersion>, but end tag </IfDefine>
Comment 19 Josef Moravec 2015-08-17 06:11:54 UTC
And I had to install starman and perl module Plack::Middleware::ReverseProxy

shouldn't it be at least documented somewhere?
Comment 20 Tomás Cohen Arazi 2015-08-17 12:09:53 UTC
(In reply to Josef Moravec from comment #19)
> And I had to install starman and perl module Plack::Middleware::ReverseProxy
> 
> shouldn't it be at least documented somewhere?

I'll fix both. Thanks Josef
Comment 21 Tomás Cohen Arazi 2015-08-17 13:46:16 UTC Comment hidden (obsolete)
Comment 22 Tomás Cohen Arazi 2015-08-17 13:46:25 UTC Comment hidden (obsolete)
Comment 23 Tomás Cohen Arazi 2015-08-17 13:46:30 UTC Comment hidden (obsolete)
Comment 24 Tomás Cohen Arazi 2015-08-17 13:46:35 UTC Comment hidden (obsolete)
Comment 25 Tomás Cohen Arazi 2015-08-17 13:46:40 UTC Comment hidden (obsolete)
Comment 26 Tomás Cohen Arazi 2015-08-17 13:46:46 UTC Comment hidden (obsolete)
Comment 27 Josef Moravec 2015-08-18 08:02:03 UTC Comment hidden (obsolete)
Comment 28 Josef Moravec 2015-08-18 08:02:12 UTC Comment hidden (obsolete)
Comment 29 Josef Moravec 2015-08-18 08:02:19 UTC Comment hidden (obsolete)
Comment 30 Josef Moravec 2015-08-18 08:02:26 UTC Comment hidden (obsolete)
Comment 31 Josef Moravec 2015-08-18 08:02:33 UTC Comment hidden (obsolete)
Comment 32 Josef Moravec 2015-08-18 08:02:40 UTC Comment hidden (obsolete)
Comment 33 Jonathan Druart 2015-08-20 16:19:35 UTC
root@koha-deb:/usr/sbin# koha-plack --disable library
Plack disabled for library
root@koha-deb:/usr/sbin# koha-plack --enable library
Plack already enabled for library

hum?

Not sure I have tested correctly, back on this one tomorrow.
Comment 34 Tomás Cohen Arazi 2015-08-20 17:09:58 UTC
(In reply to Jonathan Druart from comment #33)
> root@koha-deb:/usr/sbin# koha-plack --disable library
> Plack disabled for library
> root@koha-deb:/usr/sbin# koha-plack --enable library
> Plack already enabled for library
> 
> hum?
> 
> Not sure I have tested correctly, back on this one tomorrow.

Hi Jonathan!

1) It seems to me that the script is not catching the absense of the relevant line on your site's virtualhosts definition. This could be a bug in koha-functions.sh (is_plack_enabled). Probably not using the right koha-functions.sh (look at (4).

2) You should be looking  at /var/log/koha/<instance>/plack-output.log to know if you are on plack. But you should notice, you know... it is slightly super faster. When you have plack enabled a line like this is uncommented in /etc/apache2/sites-enabled/<instance>.conf:

OPAC:
# Include /etc/koha/apache-shared-opac-plack.conf

Intranet:
# Include /etc/koha/apache-shared-intranet-plack.conf

Those files need to be present in those dirs (look at (4) for details).

3) You need to know that koha-plack --enable <instance> is not starting the daemon for now, so you need to issue koha-plack --start <instance> to have it running. This is independent from the Apache conf hook, so Plack might be running but not being used. You can ps waux | grep starman (there should be a master process with two workers).

4) Where the files are put is really important because they are picked to generate a suitable apache configuration, otherwise it won't work.:

debian/templates/apache-shared-*-plack.conf -> /etc/koha
debian/templates/apache-site.conf.in -> /etc/koha
debian/koha-common.bash-completion -> /etc/bash_completion.d/koha-common
debian/scripts/koha-functions.sh -> /usr/share/koha/bin
debian/scripts/koha-* -> /usr/sbin

The template files need to be put in place BEFORE the instance is created.

I think I'll build the packages for this so testing is pretty easier. Also note that you need to install
- starman
- libplack-middleware-reverseproxy-perl

Thanks for your time testing this!
Comment 35 Jonathan Druart 2015-08-21 08:35:56 UTC
Thanks a lot for this additional information, it's very useful.

I had to restart apache2 to take into account the change (I suppose it's intended).
But... I got an error on the mainpage:

==> /var/log/koha/library-plack/plack-error.log <==
Could not compile /usr/share/koha/intranet/cgi-bin/mainpage.pl: Attempt to reload C4/Auth.pm aborted.
Compilation failed in require at /usr/share/koha/intranet/cgi-bin/mainpage.pl line 25.
BEGIN failed--compilation aborted at /usr/share/koha/intranet/cgi-bin/mainpage.pl line 25.

I successfully access to / but got this error on /cgi-bin/koha/mainpage.pl

Not caused by this patch.

Marked as Passed QA, great job Tomás!
Comment 36 Jonathan Druart 2015-08-21 08:36:34 UTC
Created attachment 41748 [details] [review]
Bug 13791: Plack out-of-the-box support on packages

This patch introduces a koha-plack script that controls running Plack
processes for each instance. They are run using 'starman', listening
on a Unix Domain Socket (UDS):

  /var/run/koha/<instancename>/plack.sock

The plack configuration file[1] is expected to be on:

  /etc/koha/plack.psgi

and is installed by the package.

It also adds the following helper functions to koha-functions.sh:

 - is_plack_enabled
 - is_plack_running

Done:
- koha-plack script
- suitable psgi file

To test this patches you will need to install
- starman
- libplack-middleware-reverseproxy-perl

[1] Yeah, a single file. Because we will be relying on multiple mount
points for each "app" (i.e. 'opac' and 'intranet', and 'api' ;-) )

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 37 Jonathan Druart 2015-08-21 08:36:38 UTC
Created attachment 41749 [details] [review]
Bug 13791: Apache configuration files

This patch adds an include to each VirtualHost definition (OPAC and Intranet)
and a variable definition, taking advantage of Apache 2.4.x features.

The instance name is reused inside the includes providing a simple way of
dealing with the apache <-> plack configuration.

A check for the right apache version is introduced, in the for of an IfVersion block:

<IfVersion >= 2.4>
  --- Plack configuration here ---
</IfVersion>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 38 Jonathan Druart 2015-08-21 08:36:41 UTC
Created attachment 41750 [details] [review]
Bug 13791: koha-plack documentation

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 39 Jonathan Druart 2015-08-21 08:36:45 UTC
Created attachment 41751 [details] [review]
Bug 13791: make koha-list aware of plack

This patch adds the --plack and --noplack option switches to koha-list
for filtering instances to be listed.

This is particularly important for init scripts and cronjobs.

To test:
- Play with koha-list --plack and koha-plack --enable/--disable and verify that
koha-list returns the expected results.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 40 Jonathan Druart 2015-08-21 08:36:49 UTC
Created attachment 41752 [details] [review]
Bug 13791: make koha-common init script aware of plack

This patch makes the packages' koha-common script aware of plack.
It does so by relying on koha-list --plack to know which instances
have Plack configured, and uses the koha-plack script to manage
the running daemons.

It also introduces a plack_status function to check the status of
the Plack daemon when called:

   $ servive koha-common status

Regards

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 41 Jonathan Druart 2015-08-21 08:36:52 UTC
Created attachment 41753 [details] [review]
Bug 13791: tab-completion for koha-plack in bash

This patch adds tab-completion in bash for the koha-plack command.

After the --start, --stop, --restart and --disable switches it only offers
plack-enabled instances.  And disabled instances to --enable.

--help and -h just finish end the completion.

--quiet and -q are trickier to implement. They will work (be offered)
only before the action switches.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 42 Jonathan Druart 2015-08-21 08:38:19 UTC
I would be really useful to have the ability to enable plack for the OPAC or staff side only (since the staff is not stable yet...)
Comment 43 Jonathan Druart 2015-08-21 08:40:10 UTC
(In reply to Jonathan Druart from comment #35)
> Thanks a lot for this additional information, it's very useful.
> 
> I had to restart apache2 to take into account the change (I suppose it's
> intended).
> But... I got an error on the mainpage:
> 
> ==> /var/log/koha/library-plack/plack-error.log <==
> Could not compile /usr/share/koha/intranet/cgi-bin/mainpage.pl: Attempt to
> reload C4/Auth.pm aborted.
> Compilation failed in require at
> /usr/share/koha/intranet/cgi-bin/mainpage.pl line 25.
> BEGIN failed--compilation aborted at
> /usr/share/koha/intranet/cgi-bin/mainpage.pl line 25.
> 
> I successfully access to / but got this error on /cgi-bin/koha/mainpage.pl
> 
> Not caused by this patch.

And actually all other pages
Comment 44 Jonathan Druart 2015-08-21 08:46:23 UTC
So, the install where I have tried this page is 3.2002000.
I have tried with a git install, checkouted 3.20.02, and I don't get the error.
Comment 45 Mike 2015-08-21 08:50:29 UTC
(In reply to Jonathan Druart from comment #43)
Helo,
I want to confirm same problem in staff side.

Mike

> Thanks a lot for this additional information, it's very useful.
> 
> I had to restart apache2 to take into account the change (I suppose it's
> intended).
> But... I got an error on the mainpage:
> 
> ==> /var/log/koha/library-plack/plack-error.log <==
> Could not compile /usr/share/koha/intranet/cgi-bin/mainpage.pl: Attempt to
> reload C4/Auth.pm aborted.
> Compilation failed in require at
> /usr/share/koha/intranet/cgi-bin/mainpage.pl line 25.
> BEGIN failed--compilation aborted at
> /usr/share/koha/intranet/cgi-bin/mainpage.pl line 25.
> 
> I successfully access to / but got this error on /cgi-bin/koha/mainpage.pl
> 
> Not caused by this patch.

And actually all other pages
Comment 46 Tomás Cohen Arazi 2015-08-24 16:13:45 UTC
Created attachment 41866 [details] [review]
Bug 13791: (QA followup) Plack support requires Apache 2.4.8+

The Apache 2.4 documentation says UDS support for ProxyPass has been
introduced in Apache 2.4.7. That's what is shipped by Koha's supported
Debian / Ubuntu versions.
But it is not true, empiric tests and even the changelog for the apache
project says the feature got introduced in 2.4.8. So to avoid breakages
I raised the version number test on the apache files to 2.4.8.

New bugs will be filled for dealing with this if we find it necessary.

Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
Comment 47 Tomás Cohen Arazi 2015-08-24 16:16:51 UTC
Patches pushed to master.

Farewell, CGI.
Comment 48 Tomás Cohen Arazi 2015-08-27 16:19:00 UTC
Created attachment 42038 [details] [review]
Bug 13791: (RM followup) Add new dependencies for packaging

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 49 Magnus Enger 2015-10-09 07:23:32 UTC
Traditionally, changes to the koha-*scripts have been backported to stable releases, so that the tools around package installations are the same, no matter what version they are running. Could/should this be considered for the present bug too, or is it too big a leap to incorporate it into the stable branches?
Comment 50 Mirko Tietgen 2015-11-29 12:56:24 UTC
Applies cleanly to 3.20.5.
Needs tiny fix for 3.18.12 in debian/control.

Adds new dependencies (not mandatory if koha-plack is not used).
Needs Apache 2.4 (Debian Jessie, Ubuntu ?).