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

[PATCH 4/4] git-instaweb: Check that correct config file exists for (re)start

From
Jakub Narebski <jnareb@gmail.com>
Date
Jun 23, 2011, 21:01 UTC
Message-ID
<20110623205942.18265.5903.stgit@localhost.localdomain>
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
 
Previous: Jakub NarebskiNext: Eric Wong
Message 9 of 10 in “Having some problem with instaweb”
  1. Gurjeet SinghJun 23, 2011
  2. Jakub NarebskiJun 23, 2011
  3. Gurjeet SinghJun 23, 2011
  4. Jakub NarebskiJun 23, 2011
  5. 0/4 git-instaweb: Improving handling of --start/--restartJakub Narebski, Jun 23, 2011
  6. 1/4 git-instaweb: Extract configuring web server into configure_httpdJakub Narebski, Jun 23, 2011
  7. 2/4 git-instaweb: Use $conf, not $fqgitdir/gitweb/httpd.confJakub Narebski, Jun 23, 2011
  8. 3/4 git-instaweb: Move all actions at the end of scriptJakub Narebski, Jun 23, 2011
  9. 4/4 git-instaweb: Check that correct config file exists for (re)startJakub Narebski, Jun 23, 2011
  10. Eric WongJun 28, 2011

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.