{"thread":{"id":"23665","subject":"Adding support for \"plackup\" and similar web server tools to git-instaweb","startedAt":"2010-05-02T01:17:40Z","lastAt":"2010-05-03T22:25:51Z","messageCount":3,"participants":["Jakub Narebski","Eric Wong"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"140718","messageId":"201005020317.42112.jnareb@gmail.com","threadId":"23665","inReplyTo":null,"subject":"Adding support for \"plackup\" and similar web server tools to git-instaweb","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-05-02T01:17:40Z","receivedAt":"2010-05-02T01:17:40Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"I would like to add support for --httpd / instaweb.httpd = plackup\nto git-instaweb.  'plackup'[1] is a command line utility to run \nPSGI[2][3] application (CGI application can be wrapped as such[4][5])\nfrom the command line.  \n\nAmong others 'plackup' can use standalone HTTP::Server::PSGI server\n(in Perl).  This means that one could use git-instaweb with \n--httpd=plackup even without permissions to install CGI scripts;\nwithout admin rights (CPAN modules can be installed localy in one's\nhome directory using local::lib).\n\n\nThe problem is that contrary to other web servers that can be used by\ngit-instaweb, (namely apache2, lighttpd, mongoose and webrick), the\n'plackup' utility is configured using command line options, and not\nvia configuration file (well, one can use configuration file, but it\ndepends on the web server run from plackup).\n\nHow should one go with adding support for such httpd?  My first attempt\nwas putting full command line into 'httpd' in resolve_full_httpd():\n\n+       *plackup*)\n+               # plackup is configured via command-line options\n+               bind=\n+               test x\"$local\" = xtrue && bind=\"--host=127.0.0.1\"\n+               httpd=\"$httpd --port=$port $bind --app=$fqgitdir/gitweb/app.psgi\"\n+               ;;\n\nThe default standalone web server used by plackup (HTTP::Server::PSGI)\ndoes not have daemon mode, so we would have to do the same as for moongose\nweb server: set to background and save pid in pidfile in git-instaweb.\n\nOTOH plackup prints information / logs to STDERR, so it would have to be\nsilenced or redirected to error_log.  Also plackup does not need to have\n\"$fqgitdir/gitweb/httpd.conf\" passed as last argument, but it needs to\nbe passed PSGI wrapper for CGI (I'd rather not use httpd.conf, but rather\napp.psgi or gitweb.psgi for that).\n\n\nSo how should one go with adding support for new web server to git-instaweb,\nthat is configured via command line options (--port, --host) and not via\nconfig file?\n\n[1] http://p3rl.org/plackup\n[2] http://plackperl.org\n[3] http://p3rl.org/PSGI\n[4] http://p3rl.org/Plack::App::WrapCGI\n[5] http://p3rl.org/CGI::Emulate::PSGI\n[6] http://p3rl.org/Plack\n-- \nJakub Narebski\nPoland\n"},{"id":"140850","messageId":"20100503205624.GA3791@dcvr.yhbt.net","threadId":"23665","inReplyTo":"201005020317.42112.jnareb@gmail.com","subject":"Re: Adding support for \"plackup\" and similar web server tools to git-instaweb","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2010-05-03T20:56:24Z","receivedAt":"2010-05-03T20:56:24Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"Jakub Narebski <jnareb@gmail.com> wrote:\n> The problem is that contrary to other web servers that can be used by\n> git-instaweb, (namely apache2, lighttpd, mongoose and webrick), the\n> 'plackup' utility is configured using command line options, and not\n> via configuration file (well, one can use configuration file, but it\n> depends on the web server run from plackup).\n> \n> How should one go with adding support for such httpd?  My first attempt\n> was putting full command line into 'httpd' in resolve_full_httpd():\n> \n> +       *plackup*)\n> +               # plackup is configured via command-line options\n> +               bind=\n> +               test x\"$local\" = xtrue && bind=\"--host=127.0.0.1\"\n> +               httpd=\"$httpd --port=$port $bind --app=$fqgitdir/gitweb/app.psgi\"\n> +               ;;\n> \n> The default standalone web server used by plackup (HTTP::Server::PSGI)\n> does not have daemon mode, so we would have to do the same as for moongose\n> web server: set to background and save pid in pidfile in git-instaweb.\n> \n> OTOH plackup prints information / logs to STDERR, so it would have to be\n> silenced or redirected to error_log.  Also plackup does not need to have\n> \"$fqgitdir/gitweb/httpd.conf\" passed as last argument, but it needs to\n> be passed PSGI wrapper for CGI (I'd rather not use httpd.conf, but rather\n> app.psgi or gitweb.psgi for that).\n> \n> \n> So how should one go with adding support for new web server to git-instaweb,\n> that is configured via command line options (--port, --host) and not via\n> config file?\n\nHi Jakub,\n\nHow about generating a small shell script that wraps plackup with the\nappropriate command-line options?\n\n-- \nEric Wong\n"},{"id":"140857","messageId":"201005040025.53473.jnareb@gmail.com","threadId":"23665","inReplyTo":"20100503205624.GA3791@dcvr.yhbt.net","subject":"Re: Adding support for \"plackup\" and similar web server tools to git-instaweb","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-05-03T22:25:51Z","receivedAt":"2010-05-03T22:25:51Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Mon, 3 May 2010, Eric Wong wrote:\n> Jakub Narebski <jnareb@gmail.com> wrote:\n> >\n> > The problem is that contrary to other web servers that can be used by\n> > git-instaweb, (namely apache2, lighttpd, mongoose and webrick), the\n> > 'plackup' utility is configured using command line options, and not\n> > via configuration file (well, one can use configuration file, but it\n> > depends on the web server run from plackup).\n> > \n> > How should one go with adding support for such httpd?  My first attempt\n> > was putting full command line into 'httpd' in resolve_full_httpd():\n> > \n> > +       *plackup*)\n> > +               # plackup is configured via command-line options\n> > +               bind=\n> > +               test x\"$local\" = xtrue && bind=\"--host=127.0.0.1\"\n> > +               httpd=\"$httpd --port=$port $bind --app=$fqgitdir/gitweb/app.psgi\"\n> > +               ;;\n[...]\n> > So how should one go with adding support for new web server to git-instaweb,\n> > that is configured via command line options (--port, --host) and not via\n> > config file?\n> \n> How about generating a small shell script that wraps plackup with the\n> appropriate command-line options?\n\n RFC1925 - The Twelve Networking Truths                      1 April 1996\n \n 2. The Fundamental Truths\n\n         (6a) (corollary). It is always possible to add another level of\n              indirection.\n\nJust kidding...\n\n\nMore seriously, even currently in git-instaweb the 'httpd' variable\ncontains web server invocation *with options* (see the case of apache2\nand lighttpd, where resolve_full_httpd() ensures that 'httpd' ends\nwith '-f' in such case.  Using 'httpd' variable to be plackup-with-options\nnaturally follows from such example.\n\nShell script (plackup.sh?  gitweb-plackup.sh?  instaweb-plackup.sh?)\nmight be good idea, though.  Note that we have to create gitweb.psgi\n(or app.psgi) CGI-to-PSGI wrapper (and to serve static files like \ngitweb.css) anyway by git-instaweb.\n\n-- \nJakub Narebski\nPoland\n"}]}