git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC/PATCH] git-instaweb: Add support for running gitweb via 'plackup'

From
Jakub Narebski <jnareb@gmail.com>
Date
May 19, 2010, 20:52 UTC
Message-ID
<201005192252.49461.jnareb@gmail.com>
In-Reply-To
<1274290298-19245-1-git-send-email-jnareb@gmail.com>
On Wed, 19 May 2010, Jakub Narebski wrote:
> ---
[...]
Show 16 quoted lines
> RFC is because when when running
> 
>   $ ./git-instaweb --httpd=plackup --browser=lynx
> 
> I get the following error
> 
>   Looking up 127.0.0.1:1234
>   Making HTTP connection to 127.0.0.1:1234
>   Alert!: Unable to connect to remote host.
> 
>   lynx: Can't access startfile http://127.0.0.1:1234/
>   http://127.0.0.1:1234
> 
> But running 'lynx http://127.0.0.1:1234/' after this works correctly
> without problems.  Running './.git/gitweb/gitweb.psgi' doesn't cause
> any problems either.  WTF?

I think I know what might be happening here. The plackup / Plack::Runner needs some time to setup and start running HTTP::Server::PSGI based web server. When it is ready to serve requests (web pages), it prints to stderr

  <server>: Accepting connections at http://<host>:<port>/

In the case of .git/gitweb/gitweb.psgi script generated by git-instaweb it is:

  HTTP::Server::PSGI: Accepting connections at http://0:1234/

But plackup / Plack::Runner is run in background (HTTP::Server::PSGI does not support '--daemonize'), and most probably the web browser is started before web server is not ready.

Do you have any idea on how to synchronize those two processes, the web server and the web client (web browser), so that web browser is run only after web server prints that it is ready to accept connection?

TIA.
Show 13 quoted lines
> @@ -83,9 +90,9 @@ start_httpd () {
>  
>  	# don't quote $full_httpd, there can be arguments to it (-f)
>  	case "$httpd" in
> -	*mongoose*)
> -		#The mongoose server doesn't have a daemon mode so we'll have to fork it
> -		$full_httpd "$fqgitdir/gitweb/httpd.conf" &
> +	*mongoose*|*plackup*)
> +		#The mongoose server and plackup don't have a daemon mode so we'll have to fork it
> +		$full_httpd "$fqgitdir/gitweb/httpd.conf" 2>"$fqgitdir/error_log" &
>  		#Save the pid before doing anything else (we'll print it later)
>  		pid=$!
>  
-- 
Jakub Narebski
Poland
Previous: Jakub NarebskiNext: Jakub Narebski
Message 2 of 12 in “git-instaweb: Add support for running gitweb via 'plackup'”
  1. git-instaweb: Add support for running gitweb via 'plackup'Jakub Narebski, May 19, 2010
  2. Jakub NarebskiMay 19, 2010
  3. [PATCHv2 (RFC)] git-instaweb: Add support for running gitweb via 'plackup'Jakub Narebski, May 20, 2010
  4. [RFC/PATCHv3] git-instaweb: Add support for running gitweb via 'plackup'Jakub Narebski, May 20, 2010
  5. Jakub NarebskiMay 22, 2010
  6. Eric WongMay 23, 2010
  7. Jakub NarebskiMay 23, 2010
  8. Ævar Arnfjörð BjarmasonMay 23, 2010
  9. Jakub NarebskiMay 25, 2010
  10. Jakub NarebskiMay 25, 2010
  11. Eric WongMay 23, 2010
  12. Jakub NarebskiMay 23, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.