Skip to contentSkip to conversation

Having some problem with instaweb

PATCH In review Gurjeet Singh 3 participants 10 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

I am on Linux Mint 10 and I tried the following command:

$ git instaweb -d apache2 -p 1234 --start
Syntax error on line 1 of /mnt/storage/gurjeet/.git/gitweb/httpd.conf:
Invalid command 'server.document-root', perhaps misspelled or defined
by a module not included in the server configuration
Could not execute http daemon apache2 -f.

/mnt/storage/gurjeet/ is my $HOME.

I have tried commenting out that first line, but then the error complains about line 2 'server.port = 1234'

Any help appreciated.

Thanks in advance.

PS: I am told that no subscription is required on this mailing list, since people usually do reply-all; so relying on that.
--
Gurjeet Singh
EnterpriseDB Corporation
The Enterprise PostgreSQL Company

#1 lore raw

CC-ing Eric Wong, author of git-instaweb.

Quoted 7 lines · Gurjeet Singh

I am on Linux Mint 10 and I tried the following command:

$ git instaweb -d apache2 -p 1234 --start
Syntax error on line 1 of /mnt/storage/gurjeet/.git/gitweb/httpd.conf:
Invalid command 'server.document-root', perhaps misspelled or defined
by a module not included in the server configuration
Could not execute http daemon apache2 -f.

Hmmm... it looks like starts apache2, but generates config file (httpd.conf) for lighttpd instead.

Ahh... actually you started apache2, but didn't generate configuration file for it, so git-instaweb re-uses previous config file... which by default is lighttpd:

start, --start
Start the httpd instance and exit. This does not generate any of the configuration files for spawning a new instance.

Try using

  $ git instaweb -d apache2 -p 1234 -b lynx

then exiting web browser.

BTW. I think that git-instaweb should be more helpful here... will investigate.

Quoted 1 line

/mnt/storage/gurjeet/ is my $HOME.

Nb. it doesn't mater where $HOME is, but where is git repository you were in when calling git-instaweb.

BTW. in the future it would be good idea to tell what git version are you using.

Signature · 3 lines
Jakub Narebski
Poland
ShadeHawk on #git
#2 lore raw
Quoted 15 lines · Jakub Narebski

CC-ing Eric Wong, author of git-instaweb.

Quoted 7 lines · Gurjeet Singh

I am on Linux Mint 10 and I tried the following command:

$ git instaweb -d apache2 -p 1234 --start
Syntax error on line 1 of /mnt/storage/gurjeet/.git/gitweb/httpd.conf:
Invalid command 'server.document-root', perhaps misspelled or defined
by a module not included in the server configuration
Could not execute http daemon apache2 -f.

Hmmm... it looks like starts apache2, but generates config file (httpd.conf) for lighttpd instead.

Quoted 7 lines

Ahh... actually you started apache2, but didn't generate configuration file for it, so git-instaweb re-uses previous config file... which by default is lighttpd:

 start, --start
     Start the httpd instance and exit. This does not generate any of the configuration files for spawning a new instance.

Now that's very unintuitive.... I am the impatient kind, and didn't read the whole paragraph. I assumed --start would just start the webserver (maybe run in daemon mode).

Quoted 4 lines

Try using

 $ git instaweb -d apache2 -p 1234 -b lynx

That worked.. I do not have lynx, but it did start apache2 and I was able to browse the repo.

Quoted 11 lines

then exiting web browser.

BTW. I think that git-instaweb should be more helpful here... will investigate.

Quoted 1 line

/mnt/storage/gurjeet/ is my $HOME.

Nb. it doesn't mater where $HOME is, but where is git repository you were in when calling git-instaweb.

Got it. I have some files of my home directory in a Git repository, so $HOME is where the repository is.

I have quite a few development related Git repositories under $HOME/dev/ and instaweb shows all of them on the first page (with description etc). IOW, is it supposed to recurse down all directories to look for .git/ directories?

.git
dev/EDB-ADVISORS/.git
dev/EDBAS/.git
dev/PCS/.git
dev/PEM/.git
dev/PGAGENT/.git
dev/POSTGRES/.git
dev/SERVICESTOOLS/.git
dev/SLONY/.git

Is this expected?

Quoted 4 lines

BTW. in the future it would be good idea to tell what git version are you using.

I am at 1.7.1

Thanks for the help, and thanks to everyone around Git for a great piece of software.

Signature · 3 lines
Gurjeet Singh
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
#3 lore raw
Quoted 18 lines · Gurjeet Singh
Quoted 17 lines · Jakub Narebski
Quoted 7 lines · Gurjeet Singh

I am on Linux Mint 10 and I tried the following command:

$ git instaweb -d apache2 -p 1234 --start
Syntax error on line 1 of /mnt/storage/gurjeet/.git/gitweb/httpd.conf:
Invalid command 'server.document-root', perhaps misspelled or defined
by a module not included in the server configuration
Could not execute http daemon apache2 -f.

Hmmm... it looks like starts apache2, but generates config file (httpd.conf) for lighttpd instead.

Ahh... actually you started apache2, but didn't generate configuration file for it, so git-instaweb re-uses previous config file... which by default is lighttpd:

Quoted 7 lines
Quoted 3 lines

 start, --start
     Start the httpd instance and exit. This does not generate any of the configuration files for spawning a new instance.

Now that's very unintuitive.... I am the impatient kind, and didn't read the whole paragraph. I assumed --start would just start the webserver (maybe run in daemon mode).

I'm working on it... actually the patch series is ready to send; it will be sent as a reply to this email.

I just hope that it wouldn't be lost being deeper in thread...

Quoted 23 lines
Quoted 4 lines
Quoted 1 line

/mnt/storage/gurjeet/ is my $HOME.

Nb. it doesn't mater where $HOME is, but where is git repository you were in when calling git-instaweb.

Got it. I have some files of my home directory in a Git repository, so $HOME is where the repository is.

I have quite a few development related Git repositories under $HOME/dev/ and instaweb shows all of them on the first page (with description etc). IOW, is it supposed to recurse down all directories to look for .git/ directories?

.git
dev/EDB-ADVISORS/.git
dev/EDBAS/.git
dev/PCS/.git
dev/PEM/.git
dev/PGAGENT/.git
dev/POSTGRES/.git
dev/SERVICESTOOLS/.git
dev/SLONY/.git

Quoted 1 line

Is this expected?

It is expected behavior.

It is consequence of the fact that the default gitweb mode is to search for repositories recursively starting from given root; git-instaweb set this $projectsroot to the one directory up from $GIT_DIR. Alternate solution would be for git-instaweb to generate projects list file for gitweb with only single repository listed...

Nevertheless usually you don't have repositories inside of working directory of other repositories. There was even idea floated to deprecate such support, but it didn't gained traction.

One expected exception is when you use _submodules_; in this case you would probably want to see both supermodule and submodules (subrepositories).

That is why I think that current git-instaweb behavior has sense.

Signature · 2 lines
Jakub Narebski
Poland
#4 lore raw

cover git-instaweb: Improving handling of --start/--restart

This series fixes the issue reported by Gurheet Singh in "Having some problem with instaweb", in that --start/--restart doesn't generate configuration, which is documented:

start, --start
Start the httpd instance and exit. This does not generate any of the configuration files for spawning a new instance.

but unexpected.

The first three patches are independent refactoring to make final change smaller and easier to review, thoug they have merit even taken standalone.

---
Jakub Narebski (4):
git-instaweb: Check that correct config file exists for (re)start
git-instaweb: Move all actions at the end of script
git-instaweb: Use $conf, not $fqgitdir/gitweb/httpd.conf
git-instaweb: Extract web server configuration into configure_httpd

 Documentation/git-instaweb.txt |    8 ++--
 git-instaweb.sh                |   84 ++++++++++++++++++++++++++--------------
 2 files changed, 58 insertions(+), 34 deletions(-)
Signature · 3 lines
Jakub Narebski
ShadeHawk on #git
Poland
#5 lore raw

PATCH 1/4 git-instaweb: Extract configuring web server into configure_httpd

This is preparatory work for making start/restart check that git-instaweb set up correct configuration, and generate it if it is missing.

Pure refactoring, no functional changes.

---
As usual, you can check this change with

  $ git blame -w --date=short -C -C HEAD^.. -- git-instaweb.sh |
    grep -C 3 -e '^[^^]' | less -S

assuming that it is checked out (HEAD == this commit).

Thanks Junio for the tip!

Nb. it would be nice to have an option to 'git diff' which would function like '-w' but ignore code movement...

 git-instaweb.sh |   46 +++++++++++++++++++++++++---------------------
 1 files changed, 25 insertions(+), 21 deletions(-)
git-instaweb.sh +25 -21
index 8bfa8a0..49bab7b 100755
@@ -587,32 +587,36 @@ our \$projects_list = \$projectroot;
 EOF
 }
 
+configure_httpd() {
+	case "$httpd" in
+	*lighttpd*)
+		lighttpd_conf
+		;;
+	*apache2*|*httpd*)
+		apache2_conf
+		;;
+	webrick)
+		webrick_conf
+		;;
+	*mongoose*)
+		mongoose_conf
+		;;
+	*plackup*)
+		plackup_conf
+		;;
+	*)
+		echo "Unknown httpd specified: $httpd"
+		exit 1
+		;;
+	esac
+}
+
 gitweb_conf
 
 resolve_full_httpd
 mkdir -p "$fqgitdir/gitweb/$httpd_only"
 
-case "$httpd" in
-*lighttpd*)
-	lighttpd_conf
-	;;
-*apache2*|*httpd*)
-	apache2_conf
-	;;
-webrick)
-	webrick_conf
-	;;
-*mongoose*)
-	mongoose_conf
-	;;
-*plackup*)
-	plackup_conf
-	;;
-*)
-	echo "Unknown httpd specified: $httpd"
-	exit 1
-	;;
-esac
+configure_httpd
 
 start_httpd
 url=http://127.0.0.1:$port
#6 lore raw

PATCH 2/4 git-instaweb: Use $conf, not $fqgitdir/gitweb/httpd.conf

In reply to Jakub Narebski

Don't repeat yourself: use "$conf" instead of its [current] contents, namely "$fqgitdir/gitweb/httpd.conf".

---
Straighforward improvement. Note that currently $conf is constant, and doesn't change its value.

 git-instaweb.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
git-instaweb.sh +2 -2
index 49bab7b..2be22a0 100755
@@ -103,7 +103,7 @@ start_httpd () {
 	case "$httpd" in
 	*mongoose*|*plackup*)
 		#These servers don't have a daemon mode so we'll have to fork it
-		$full_httpd "$fqgitdir/gitweb/httpd.conf" &
+		$full_httpd "$conf" &
 		#Save the pid before doing anything else (we'll print it later)
 		pid=$!
 
@@ -117,7 +117,7 @@ $pid
 EOF
 		;;
 	*)
-		$full_httpd "$fqgitdir/gitweb/httpd.conf"
+		$full_httpd "$conf"
 		if test $? != 0; then
 			echo "Could not execute http daemon $httpd."
 			exit 1
#7 lore raw

PATCH 3/4 git-instaweb: Move all actions at the end of script

In reply to Jakub Narebski

As a nice side-effect now the order of parameters does not matter:

  $ git instaweb --httpd=apache2 --start

is now (after this patch) the same as

  $ git instaweb --start --httpd=apache2

Before this commit --start, --stop, --restart (and their subcommand versions start, stop, restart) exited immediately.

This is preparatory work for making start/restart check that correct configuration is set up; this change was required to have access in start_httpd to requested web browser etc.

---
Unfortunately there are no tests for git-instaweb, so I couldn't test if it is really no much of a functional change.

BTW. if you thought of a better subject for this commit, please speak up.

 git-instaweb.sh |   27 ++++++++++++++++++++-------
 1 files changed, 20 insertions(+), 7 deletions(-)
git-instaweb.sh +20 -7
index 2be22a0..9a2f20f 100755
@@ -27,6 +27,7 @@ httpd="$(git config --get instaweb.httpd)"
 root="$(git config --get instaweb.gitwebdir)"
 port=$(git config --get instaweb.port)
 module_path="$(git config --get instaweb.modulepath)"
+action="browse"
 
 conf="$GIT_DIR/gitweb/httpd.conf"
 
@@ -148,17 +149,13 @@ while test $# != 0
 do
 	case "$1" in
 	--stop|stop)
-		stop_httpd
-		exit 0
+		action="stop"
 		;;
 	--start|start)
-		start_httpd
-		exit 0
+		action="start"
 		;;
 	--restart|restart)
-		stop_httpd
-		start_httpd
-		exit 0
+		action="restart"
 		;;
 	-l|--local)
 		local=true
@@ -611,6 +608,22 @@ configure_httpd() {
 	esac
 }
 
+case "$action" in
+stop)
+	stop_httpd
+	exit 0
+	;;
+start)
+	start_httpd
+	exit 0
+	;;
+restart)
+	stop_httpd
+	start_httpd
+	exit 0
+	;;
+esac
+
 gitweb_conf
 
 resolve_full_httpd
#8 lore raw

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

In reply to Jakub Narebski

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).

---
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(-)
Documentation/git-instaweb.txt +4 -4
index 08f85ba..ea95c90 100644
@@ -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
 -------------
git-instaweb.sh +7 -0
index 9a2f20f..01a1b05 100755
@@ -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
 
#9 lore raw

Re: [PATCH 0/4] git-instaweb: Improving handling of --start/--restart

In reply to Jakub Narebski
Quoted 3 lines · Jakub Narebski

This series fixes the issue reported by Gurheet Singh in "Having some problem with instaweb", in that --start/--restart doesn't generate configuration, which is documented:

Everything looks reasonable, thanks! Acked and pushed to "instaweb" branch on git://bogomips.org/git-svn.git

Signature · 1 line
Eric Wong