From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Narebski Subject: Re: [RFC/PATCH] git-instaweb: Add support for running gitweb via 'plackup' Date: Wed, 19 May 2010 22:52:46 +0200 Message-ID: <201005192252.49461.jnareb@gmail.com> References: <1274290298-19245-1-git-send-email-jnareb@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 7bit Cc: Eric Wong To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Wed May 19 22:53:02 2010 connect(): No such file or directory Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OEqGD-0001Eu-1M for gcvg-git-2@lo.gmane.org; Wed, 19 May 2010 22:53:01 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753003Ab0ESUw4 (ORCPT ); Wed, 19 May 2010 16:52:56 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:57717 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751843Ab0ESUwz (ORCPT ); Wed, 19 May 2010 16:52:55 -0400 Received: by fxm10 with SMTP id 10so2838408fxm.19 for ; Wed, 19 May 2010 13:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date :user-agent:cc:references:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:message-id; bh=JELL8YnBTzhccAqVzbXkDIJX3bcBR2ofqyBkcaULrF4=; b=cczsduAjrjEFRft/MySAWbrFNU3Q3YNfN/rmcrmoYjiiWeYkqMskd0cjV99ZiCnibx ou0d5HH+nJn19+7w6pDZIQir7LZvXKvT2zNJjoo5/WLMttE7wYgHRzrAsdUJ3oKO+kVU Z1ymALNlK/5hbSHmKFRLj8wCjloK1cBMPLb4A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding :content-disposition:message-id; b=cvrpiEfhT6KlumsboVbhv7auZHp0IstbNOpfPMQx/WUdu1+TvsJZV+s+uBncQJ15xb YtGl4xS08IlBqLJR6NtoF2eKXSwvL2aEpE5ojbW/I1P3+p/21DE3LafFxTXdZevDDFPx 3IC+0AKu0WpMvlHWamQfvHa8t6eISlqLeid34= Received: by 10.102.198.37 with SMTP id v37mr678183muf.119.1274302373516; Wed, 19 May 2010 13:52:53 -0700 (PDT) Received: from [192.168.1.13] (abrz84.neoplus.adsl.tpnet.pl [83.8.119.84]) by mx.google.com with ESMTPS id s17sm25619844bkd.22.2010.05.19.13.52.51 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 19 May 2010 13:52:51 -0700 (PDT) User-Agent: KMail/1.9.3 In-Reply-To: <1274290298-19245-1-git-send-email-jnareb@gmail.com> Content-Disposition: inline Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: On Wed, 19 May 2010, Jakub Narebski wrote: > --- [...] > 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 : Accepting connections at http://:/ 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. > @@ -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