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
EWEric Wong <normalperson@yhbt.net>
Date
May 23, 2010, 09:31 UTC
Message-ID
<20100523093120.GB3426@dcvr.yhbt.net>
In-Reply-To
<201005192252.49461.jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> wrote:
> 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?

Your polling http_is_ready() function is fine, and really the only portable solution across all servers (and OSes).

But if your webserver lets you run arbitrary code hooks after it binds the listen socket, what I do when writing integration tests is have it open a FIFO for writing.

Adapted and abridged from the Rainbows! web server test suite, the
following config snippet is from the config file for the Rainbows! web
server:
---------------- rainbows.conf.rb -----------------
after_fork do |server, worker|
  # test script will block while reading from the FIFO,
  # so notify the script on the first worker we spawn
  # by opening the FIFO
  if worker.nr == 0
    File.open("/path/to/fifo", "wb") { |fp| fp.syswrite "START" }
  end
end
---------------------------------------------------

And then in the test script: ----------- my-integration-test.sh ---------------- set -e mkfifo /path/to/fifo # start the server rainbows --daemonize --config-file rainbows.conf.rb

# "cat /path/to/fifo" will block until the after_fork hook is called # in rainbows.conf.rb test xSTART = x"$(cat /path/to/fifo)"

# server is up, run the rest of the tests... ---------------------------------------------------

-- 
Eric Wong
Previous: Jakub NarebskiNext: Jakub Narebski
Message 11 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.