git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Cc: Gurjeet Singh <singh.gurjeet@gmail.com>,
	Eric Wong <normalperson@yhbt.net>
Subject: [PATCH 4/4] git-instaweb: Check that correct config file exists for (re)start
Date: Thu, 23 Jun 2011 23:01:03 +0200	[thread overview]
Message-ID: <20110623205942.18265.5903.stgit@localhost.localdomain> (raw)
In-Reply-To: <20110623194624.18265.82482.stgit@localhost.localdomain>

Currently start/restart does not generate any configuration files for
spawning a new instance.  This means that

  $ git instaweb --http=<server> --start

might pick up stale 'httpd.conf' file for a different web server
(e.g. for default lighttpd when requesting apache2).

This commit changes that, and makes git-instaweb generate web server
config file and/or gitweb config file if don't exists.

This required naming config files after the name of web server
(alternate solution would be to somehow mark for which web server was
config file generated).

Note that web servers that embed configuration in server script file,
namely webrick and plackup, and which delete "$conf" in their *_conf
function, would have their config (server script) always regenerated.


Note: this commit introduces a bit of code repetition (but only a few
lines).

Reported-by: Gurjeet Singh <singh.gurjeet@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This is an actual fix.

Though I haven't checked if git-instaweb behaves sanely if you switch
between web servers with --start...

 Documentation/git-instaweb.txt |    8 ++++----
 git-instaweb.sh                |    7 +++++++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-instaweb.txt b/Documentation/git-instaweb.txt
index 08f85ba..ea95c90 100644
--- a/Documentation/git-instaweb.txt
+++ b/Documentation/git-instaweb.txt
@@ -51,8 +51,8 @@ OPTIONS
 
 start::
 --start::
-	Start the httpd instance and exit.  This does not generate
-	any of the configuration files for spawning a new instance.
+	Start the httpd instance and exit.  Regenerate configuration files
+	as necessary for spawning a new instance.
 
 stop::
 --stop::
@@ -62,8 +62,8 @@ stop::
 
 restart::
 --restart::
-	Restart the httpd instance and exit.  This does not generate
-	any of the configuration files for spawning a new instance.
+	Restart the httpd instance and exit.  Regenerate configuration files
+	as necessary for spawning a new instance.
 
 CONFIGURATION
 -------------
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 9a2f20f..01a1b05 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -99,6 +99,12 @@ start_httpd () {
 
 	# here $httpd should have a meaningful value
 	resolve_full_httpd
+	mkdir -p "$fqgitdir/gitweb/$httpd_only"
+	conf="$fqgitdir/gitweb/$httpd_only.conf"
+
+	# generate correct config file if it doesn't exist
+	test -f "$conf" || configure_httpd
+	test -f "$fqgitdir/gitweb/gitweb_config.perl" || gitweb_conf
 
 	# don't quote $full_httpd, there can be arguments to it (-f)
 	case "$httpd" in
@@ -628,6 +634,7 @@ gitweb_conf
 
 resolve_full_httpd
 mkdir -p "$fqgitdir/gitweb/$httpd_only"
+conf="$fqgitdir/gitweb/$httpd_only.conf"
 
 configure_httpd
 

  parent reply	other threads:[~2011-06-23 21:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-23  1:06 Having some problem with instaweb Gurjeet Singh
2011-06-23  8:23 ` Jakub Narebski
2011-06-23 11:48   ` Gurjeet Singh
2011-06-23 19:29     ` Jakub Narebski
2011-06-23 19:50       ` [PATCH 0/4] git-instaweb: Improving handling of --start/--restart Jakub Narebski
2011-06-23 19:55         ` [PATCH 1/4] git-instaweb: Extract configuring web server into configure_httpd Jakub Narebski
2011-06-23 19:56         ` [PATCH 2/4] git-instaweb: Use $conf, not $fqgitdir/gitweb/httpd.conf Jakub Narebski
2011-06-23 20:59         ` [PATCH 3/4] git-instaweb: Move all actions at the end of script Jakub Narebski
2011-06-23 21:01         ` Jakub Narebski [this message]
2011-06-28  3:22         ` [PATCH 0/4] git-instaweb: Improving handling of --start/--restart Eric Wong

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=20110623205942.18265.5903.stgit@localhost.localdomain \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=normalperson@yhbt.net \
    --cc=singh.gurjeet@gmail.com \
    /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).