Bug 7844 - plack scripts for developers
Summary: plack scripts for developers
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Dobrica Pavlinusic
QA Contact: Ian Walls
URL:
Keywords:
Depends on: 7847
Blocks: 7172
  Show dependency treegraph
 
Reported: 2012-03-29 09:56 UTC by Dobrica Pavlinusic
Modified: 2015-06-04 23:23 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 7844 - plack intranet tooling for developers (3.41 KB, patch)
2012-03-29 11:59 UTC, Dobrica Pavlinusic
Details | Diff | Splinter Review
Bug 7844 - plack intranet tooling for developers (4.51 KB, patch)
2012-03-29 15:21 UTC, Dobrica Pavlinusic
Details | Diff | Splinter Review
Bug 7844 - plack intranet tooling for developers (4.74 KB, patch)
2012-03-31 00:49 UTC, Dobrica Pavlinusic
Details | Diff | Splinter Review
Bug 7844 - plack intranet tooling for developers (7.09 KB, patch)
2012-04-04 22:32 UTC, Dobrica Pavlinusic
Details | Diff | Splinter Review
Bug 7844 - plack shell helpers (1.80 KB, patch)
2012-04-04 22:53 UTC, Dobrica Pavlinusic
Details | Diff | Splinter Review
Bug 7844 - plack modified upstream modules (17.25 KB, patch)
2012-04-04 22:53 UTC, Dobrica Pavlinusic
Details | Diff | Splinter Review
Bug 7844 - plack intranet tooling for developers (6.89 KB, patch)
2012-04-11 12:38 UTC, Dobrica Pavlinusic
Details | Diff | Splinter Review
Bug 7844 - plack intranet tooling for developers (6.97 KB, patch)
2012-06-01 13:40 UTC, Dobrica Pavlinusic
Details | Diff | Splinter Review
Bug 7844 - plack intranet tooling for developers (8.23 KB, patch)
2012-06-10 11:02 UTC, Dobrica Pavlinusic
Details | Diff | Splinter Review
Bug 7844 - plack intranet tooling for developers (8.92 KB, patch)
2012-06-11 14:55 UTC, Dobrica Pavlinusic
Details | Diff | Splinter Review
Bug 7844 - [SIGNED-OFF] plack intranet tooling for developers (9.32 KB, patch)
2014-03-12 09:55 UTC, Magnus Enger
Details | Diff | Splinter Review
Bug 7844 - plack should redirect / to correct page (1.04 KB, patch)
2014-03-12 16:23 UTC, Dobrica Pavlinusic
Details | Diff | Splinter Review
Bug 7844 - plack intranet tooling for developers (8.63 KB, patch)
2014-03-12 17:34 UTC, Dobrica Pavlinusic
Details | Diff | Splinter Review
Bug 7844 - [SIGNED-OFF] plack intranet tooling for developers (8.98 KB, patch)
2014-03-13 08:45 UTC, Magnus Enger
Details | Diff | Splinter Review
[PASSED QA] Bug 7844 - plack intranet tooling for developers (9.03 KB, patch)
2014-03-13 13:37 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Dobrica Pavlinusic 2012-03-29 09:56:12 UTC
Last missing peace to get started with plack is tooling. 

http://wiki.koha-community.org/wiki/Plack

does provide some information, psgi files and startup scripts should also be part of main repository for easy deployment on sendboxes.
Comment 1 Dobrica Pavlinusic 2012-03-29 11:59:12 UTC Comment hidden (obsolete)
Comment 2 Dobrica Pavlinusic 2012-03-29 15:21:29 UTC Comment hidden (obsolete)
Comment 3 Dobrica Pavlinusic 2012-03-31 00:49:16 UTC Comment hidden (obsolete)
Comment 4 Alex Arnaud 2012-04-03 14:30:10 UTC
This tools are very useful. I have tested installing dependencies using ./cpanm-install.pl on debian squeeze and ubnutu 10.04 and it works on both.

However, opac-plack.sh and intranet-plack.sh seem too specifics insofar as many informations are hardcoded. For instance, "KOHA_CONF=/etc/koha/sites/$site/koha-conf.xml" could be "KOHA_CONF=/home/koha/etc/koha-conf.xml" or others. Also, if i'm not wrong, scripts assumes that user launching http server consists of the site ($site) and "-koha". It could be koha.

Plack::Middleware::Static root are also hardcoded ('/srv/koha/koha-tmpl/').

should we not make koha-conf path and user some parameters of this scripts?

For my part, with a few changes, it works well :-)
Comment 5 Dobrica Pavlinusic 2012-04-04 22:32:32 UTC Comment hidden (obsolete)
Comment 6 Dobrica Pavlinusic 2012-04-04 22:51:20 UTC
Alex, I totally agree. I was refactoring it into single script and psgi in last few days while trying to record http://blog.rot13.org/koha/koha-plack-debug.ogv

It turned out much better, but it does benefit of various additional patches to other tools used which are provided as additional patch to this bug. Feel free to skip them if you don't think they are needed in upstream Koha, they are here just as convenience so that testing features doesn't require more than bz apply to test out.

I'm using git submodules to manage those dependencies:
https://github.com/dpavlin/Koha/blob/plack/.gitmodules

Same goes for shell helpers, they are useful for development, but maybe not needed in upstream repository.

Scripts does expect koha to be installed in a way Debian packages use Koha, and I would love to keep it that way. This is how we suggest that normal people run Koha, and I expect this script to morph into "migrate to plack" in 3.10 cycle.
Comment 7 Dobrica Pavlinusic 2012-04-04 22:53:14 UTC Comment hidden (obsolete)
Comment 8 Dobrica Pavlinusic 2012-04-04 22:53:50 UTC Comment hidden (obsolete)
Comment 9 Dobrica Pavlinusic 2012-04-11 12:38:40 UTC Comment hidden (obsolete)
Comment 10 Dobrica Pavlinusic 2012-04-11 12:40:06 UTC
In the end, I decided to include just minimal plack support in this patch: koha.psgi, shell script to start it up and README file.
Comment 11 Paul Poulain 2012-06-01 09:12:14 UTC
Dobrika, hello,

I'm reviewing your patches related to plack, and find this one.
In the attachment 9113 [details] [review], is written:
+1. install plack and dependencies, using ./cpanm-install.pl

but I can't find cpanm-install.pl anywhere. Is it a mistake ?
I can see cpanm-install.pl in the attachment the attachment 8893 [details] [review], but it's an obsolete one.

Any explanation welcomed !
Comment 12 Dobrica Pavlinusic 2012-06-01 11:46:56 UTC
I removed cpanm-install.pl since installation of dependencies is something that should be done by Debian package.

I don't think that installing packages using cpanm on production is something we should recommend.

Installing dependencies is documented at wiki page http://wiki.koha-community.org/wiki/Plack but it does depend on platform availability of perl packages. Currently squeeze miss quite a few packages, while wheezy does include most packages needed for Koha.
Comment 13 Dobrica Pavlinusic 2012-06-01 13:40:21 UTC Comment hidden (obsolete)
Comment 14 Dobrica Pavlinusic 2012-06-10 11:02:40 UTC Comment hidden (obsolete)
Comment 15 Dobrica Pavlinusic 2012-06-11 14:55:57 UTC Comment hidden (obsolete)
Comment 16 Katrin Fischer 2012-08-15 04:34:42 UTC
Hi, I am not sure - does this needs to be signed-off to be included in Koha? Or do we want to store it somewhere else? Maybe in a developer-tools repository?
Comment 17 claire.hernandez@biblibre.com 2013-03-21 08:47:29 UTC
I agree about the Katrin note, could be external tool, not "koha software".
Comment 18 Katrin Fischer 2013-03-21 08:54:02 UTC
Maybe a contrib/dev-tools or similar could be created in the Koha git repository?
Comment 19 Paul Poulain 2013-03-21 08:58:05 UTC
(In reply to comment #18)
> Maybe a contrib/dev-tools or similar could be created in the Koha git
> repository?

I think that contrib/global.git is also an option, there's no need to have zillions of tiny repos.
Just use contrib/global.git & add a directory.
Comment 20 Magnus Enger 2013-08-09 11:16:55 UTC
Dobrica: Would you be OK with having this outside Koha, e.g. in contrib/global.git? 

Setting to "in discussion".
Comment 21 Galen Charlton 2013-09-23 19:21:20 UTC
My preference would be to start shipping a Plack config, actually.  Sure, it's experimental, but it's also something that seems reasonably likely to ultimately become standard within a few releases, and I feel that shuffling it off into a separate repository wouldn't help.
Comment 22 Magnus Enger 2014-03-12 09:44:05 UTC
(In reply to Galen Charlton from comment #21)
> My preference would be to start shipping a Plack config, actually.  Sure,
> it's experimental, but it's also something that seems reasonably likely to
> ultimately become standard within a few releases, and I feel that shuffling
> it off into a separate repository wouldn't help.

I agree wholeheartedly with Galen now. I think speed is really important for the future growth of Koha, and Plack seems to be the speediest route to getting more speed. So let's get something into Koha that makes it as easy as possible to test Koha under Plack for as many people as possible, so we can iron out the bugs we know are lurking in the corners. 

I don't know enough about configuring Plack to say if the patch from Dobrica is optimal in every sense, but it does make it easy for me to test Koha under Plack, so I am happy to sign it off. Then we can argue about what the default settings should be, as well as add more options to plackup.sh, over time. And we can perhaps elvolve this starting point into two branches, one for testing as well as one sane baseline setup for production use.
Comment 23 Magnus Enger 2014-03-12 09:54:42 UTC
Ooops, I set the wrong status...
Comment 24 Magnus Enger 2014-03-12 09:55:07 UTC Comment hidden (obsolete)
Comment 25 Dobrica Pavlinusic 2014-03-12 16:23:27 UTC Comment hidden (obsolete)
Comment 26 Magnus Enger 2014-03-12 16:34:58 UTC
Sorry Dobrica, with the second patch I get:

$ git bz apply 7844
Bug 7844 - plack scripts for developers

26148 - Bug 7844 - [SIGNED-OFF] plack intranet tooling for developers
26201 - Bug 7844 - plack should redirect / to correct page

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 7844 - [SIGNED-OFF] plack intranet tooling for developers
Applying: Bug 7844 - plack should redirect / to correct page
fatal: sha1 information is lacking or useless (misc/plack/koha.psgi).
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Patch failed at 0001 Bug 7844 - plack should redirect / to correct page
When you have resolved this problem run "git bz apply --continue".
If you would prefer to skip this patch, instead run "git bz apply --skip".
To restore the original branch and stop patching run "git bz apply --abort".
Patch left in /tmp/Bug-7844---plack-should-redirect--to-correct-page-U01YNR.patch
Comment 27 Dobrica Pavlinusic 2014-03-12 17:12:07 UTC
Strange. Did you start from clean master? In my tests it does trigger 3-way merge, but it does succeed...

dpavlin@koha-dev:/srv/koha(bug_7844) $ git bz apply 7844
Bug 7844 - plack scripts for developers

26148 - Bug 7844 - [SIGNED-OFF] plack intranet tooling for developers
26201 - Bug 7844 - plack should redirect / to correct page

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 7844 - [SIGNED-OFF] plack intranet tooling for developers
Applying: Bug 7844 - plack should redirect / to correct page
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging misc/plack/koha.psgi
Comment 28 Dobrica Pavlinusic 2014-03-12 17:34:11 UTC Comment hidden (obsolete)
Comment 29 Dobrica Pavlinusic 2014-03-12 17:35:30 UTC
I just squashed both patches together and updated READEME not to mention missing redirects.
Comment 30 Magnus Enger 2014-03-13 08:45:44 UTC Comment hidden (obsolete)
Comment 31 Martin Renvoize (ashimema) 2014-03-13 13:37:17 UTC
Created attachment 26275 [details] [review]
[PASSED QA] Bug 7844 - plack intranet tooling for developers

koha.psgi example and plackup.sh script to run any Koha site
intranet or opac interface under plack with optional multi-process
Starman server

  plackup.sh site-name [intranet]

site-name is used to find config /etc/koha/sites/site-name/koha-conf.xml

All configuration is specified in koha.psgi, which you are welcomed to edit
and tune according to your development needs (enable memcache, enable/disable
debugging modules for plack and so on).

For deployment of opac or intranet you would probably want to take a look
in plackup.sh and enable starman as web server (which is pre-forking server
written in perl) and put some web server in front of it to serve static web
files (e.g. ngnix, apache)

When you are happy with it, rename koha.psgi and plackup.sh it to site name
and save it for safe-keeping.

This commit message is included in patch as README.plack because it includes
useful information for people using plack for first time.

Test scenario:
1. install plack and dependencies, as documented at
   http://wiki.koha-community.org/wiki/Plack

2. start ./plackup.sh sitename i[ntranet]

3. open intranet page http://localhost:5001/ and verify that it redirects
   to http://localhost:5001/cgi-bin/koha/mainpage.pl

4. start ./plackup.sh sitename

5. open OPAC http://localhost:5000/ and verify that it redirects to
   http://localhost:5000/cgi-bin/koha/opac-main.pl

6. next step is to take a look into koha.psgi and enable additional
   debug modules, save file and reload page (plackup will reload
   code automatically)

Signed-off-by: Magnus Enger <magnus@enger.priv.no>
Works as advertised. As I have explained in a comment on the bug
this looks like a very good starting point, and we can argue about
the details and add more options over time. Very happy to sign
this off! (My earlier concern about / not working has now been
taken care of, thanks Dobrica!)

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 32 Martin Renvoize (ashimema) 2014-03-13 13:41:33 UTC
More than happy to pass QA on this, and will hopefully lead to more developers running and testing plack for both intranet and opac.

Not designed for production use and happily doesn't touch anything as such.

Some thought needs to go into how this patch and bug 9316 fit together. 9316 is moving toward production, but is not fit for regular use yet.
Comment 33 Galen Charlton 2014-04-21 03:19:02 UTC
Pushed to master.  Thanks, Dobrica!