threads / discuss / 27691

Having some problem with instaweb

Subject: Having some problem with instaweb

## tl;dr

10 messages between Jun 23, 2011 and Jun 28, 2011.

replies: 9people: 3as markdown or json

Gurjeet Singh· Jun 23, 2011, 01:06 UTC · lore
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
Jakub Narebski· Jun 23, 2011, 08:23 UTC · re: Gurjeet Singh · lore

Re: Having some problem with instaweb

CC-ing Eric Wong, author of git-instaweb.
Gurjeet Singh <singh.gurjeet@gmail.com> writes:
Show 7 quoted lines
> 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.

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

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Gurjeet Singh· Jun 23, 2011, 11:48 UTC · re: Jakub Narebski · lore

Re: Having some problem with instaweb

On Thu, Jun 23, 2011 at 4:23 AM, Jakub Narebski <jnareb@gmail.com> wrote:
Show 22 quoted lines
> CC-ing Eric Wong, author of git-instaweb.
>
> Gurjeet Singh <singh.gurjeet@gmail.com> writes:
>
>> 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.

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

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

Show 11 quoted lines
>
> then exiting web browser.
>
>
> BTW. I think that git-instaweb should be more helpful here... will
> investigate.
>
>> /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?
>
>
> 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.

-- 
Gurjeet Singh
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
Jakub Narebski· Jun 23, 2011, 19:29 UTC · re: Gurjeet Singh · lore

Re: Having some problem with instaweb

On Thu, 23 Jun 2011, Gurjeet Singh wrote:
Show 25 quoted lines
> On Thu, Jun 23, 2011 at 4:23 AM, Jakub Narebski <jnareb@gmail.com> wrote:
>> Gurjeet Singh <singh.gurjeet@gmail.com> writes:
>>
>>> 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.
> 
> 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...
 
Show 24 quoted lines
>>> /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?
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.
-- 
Jakub Narebski
Poland
Jakub Narebski· Jun 23, 2011, 19:50 UTC · re: Jakub Narebski · lore

[PATCH 0/4] 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(-)
-- 
Jakub Narebski
ShadeHawk on #git
Poland
Jakub Narebski· Jun 23, 2011, 19:55 UTC · re: Jakub Narebski · lore

[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. 
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
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(-)
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 8bfa8a0..49bab7b 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -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
Jakub Narebski· Jun 23, 2011, 19:56 UTC · re: Jakub Narebski · lore

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

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

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
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(-)
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 49bab7b..2be22a0 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -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
Jakub Narebski· Jun 23, 2011, 20:59 UTC · re: Jakub Narebski · lore

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

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.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
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(-)
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 2be22a0..9a2f20f 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -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
Jakub Narebski· Jun 23, 2011, 21:01 UTC · re: Jakub Narebski · lore

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

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
 
Eric Wong· Jun 28, 2011, 03:22 UTC · re: Jakub Narebski · lore

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

Jakub Narebski <jnareb@gmail.com> wrote:
> 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

-- 
Eric Wong

← back to recent threads