From: Jakub Narebski <jnareb@gmail.com>
To: Eric Wong <normalperson@yhbt.net>
Cc: git@vger.kernel.org
Subject: Re: [RFC/PATCH] git-instaweb: Add support for running gitweb via 'plackup'
Date: Sun, 23 May 2010 22:21:34 +0200 [thread overview]
Message-ID: <201005232221.36103.jnareb@gmail.com> (raw)
In-Reply-To: <20100523093120.GB3426@dcvr.yhbt.net>
On Sun, 23 May 2010, Eric Wong wrote:
> 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).
Well, even if we use the solution below it would be good fallback for
those web servers, for which the solution below cannot be used.
>
> 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.
I was thinking about 'flock' function in Perl (and similar in other
languages), and '/usr/bin/flock' utility from util-linux. But using
FIFO as a semaphore might be a better idea: it is slighly more portable,
I guess.
Anyway, Plack handlers have (undocumented!) 'server_ready' option to web
servers, containing callback (code reference). It can be set via
parse_options method of Plack::Runner, for example. It is used by
'plackup' to print
$server: Accepting connections at $proto://$host:$port
in the (default) "development" mode.
>
> 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...
> ---------------------------------------------------
I wonder how portable is that technique...
It certainly could be done in gitweb.psgi; the question is if it is it
worth it...
--
Jakub Narebski
Poland
prev parent reply other threads:[~2010-05-23 20:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-19 17:31 [RFC/PATCH] git-instaweb: Add support for running gitweb via 'plackup' Jakub Narebski
2010-05-19 20:52 ` Jakub Narebski
2010-05-20 11:56 ` [PATCHv2 (RFC)] " Jakub Narebski
2010-05-20 21:55 ` [RFC/PATCHv3] " Jakub Narebski
2010-05-22 21:30 ` Jakub Narebski
2010-05-23 9:19 ` Eric Wong
2010-05-23 11:17 ` Jakub Narebski
2010-05-23 12:38 ` Ævar Arnfjörð Bjarmason
2010-05-25 0:11 ` Jakub Narebski
2010-05-25 9:02 ` Jakub Narebski
2010-05-23 9:31 ` [RFC/PATCH] " Eric Wong
2010-05-23 20:21 ` Jakub Narebski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201005232221.36103.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=normalperson@yhbt.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).