create new tag
, view all tags

Running TWiki under PSGI

This is just a report for an experiment: What if TWiki were to run under PSGI?

In Turning TWiki Upside Down, I complained about the annoyance "Testing SVN via webserver is too tedious". Well, that's not exactly true. It depends on the web server. It turns out that the proposed remedy to "Make TWiki runnable and browsable under my own user id" is indeed achievable using PSGI and the simple plackup server. A PSGI engine for TWiki appears to be feasible, maybe as a contrib.

The achievement and non-achievements after one evening of hacking:

  • I can run the "simple" PSGI server plackup under my own user id, and serve a correctly parsed Main/WebHome.
  • So far, I needed to change just one line in TWiki.pm to accomodate for a TWiki::Engine::PSGI engine, which has about the same amount of code as TWiki::Engine::CGI.
  • I did not yet bother with pub URLs, so the result in the browser looks strange (not in an unexpected way).
  • I have not yet tried any of the more complicated actions, just a cycle of view / edit / save (and, implicitly, login).
  • I have not yet tried to deploy the PSGI engine under a "production" web server (there are plenty of them for PSGI applications).
The benefits are:
  • No permissions problems in the SVN tree. All files and directories belong to me, unit tests and browser tests don't conflict.
  • I can run plackup with Perl's -d switch and easily trace and debug the browser interaction with arbitrary browsers and browser settings.
  • Automation of tests for persistent and non-persistent connections is just a matter of invoking plackup in appropriate setup routines.
  • And, of course, TWiki for Windows, and generally TWiki "for personal use", would work like a charm. Install and go.
-- Contributors: Harald Jörg - 2015-03-28


An all Perl solution looks like a good idea! Especially for automated testing. Thanks Harald for working on this!

Also, the TWikiForWindowsPersonal is very much outdated. It needs some TLC, and PSGI looks like a feasible way to go.

-- Peter Thoeny - 2015-04-01

Ok, let's go. I've submitted a proposal AdaptTWikiToPSGIEngineContrib for the required core changes, and I'll create Plugins.PSGIEngineContrib.

Status update: Adding pub was trivial (as I expected), I want to make it optional to run it under PSGI (if you have Apache HTTPD, serving static files doesn't need to pass through Perl). upload was a greater challenge, due to the bolt-on nature of upload fields to good ol' CGI, but works as well. Running plackup under the Perl debugger came in very handy. I have not yet touched configure at all, which is quite a different story.

-- Harald Jörg - 2015-04-01

Sounds like a plan, thanks Harald!

-- Peter Thoeny - 2015-04-02

Status update:

  • The clone of configure (lib/TWiki/Contrib/PSGIEngineContrib/Configure.pm) works with a dozen or so changes compared to bin/configure. Some (small) changes to the entrails of lib/Configure have been committed to trunk to get it working.
  • Both Starlet and starman work with the PSGI engine as of revision 28994, the latter needs a workaround for a known starman issue.
Next challenge: Building a tgz/zip containing all that's needed to run TWiki as a standalone application. An initial LocalSite.cfg should be included as well. On the plus side, all the warts related to apache in BuildingARelease (web server configuration, permissions) will vanish into thin air.

-- Harald Jörg - 2015-04-07

Thanks Jörg for working on this!

-- Peter Thoeny - 2015-04-10

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2015-04-10 - PeterThoeny
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.