@matheusbsbs / matheus-bagliano / commits / 0ded47581a
Fork 0

Add support for the Mongoose web server.

Mongoose (http://code.google.com/p/mongoose/) is a lightweight web server. It's just a single binary so it's a lot simpler to configure and install. Signed-off-by: Wilhansen Li <wil@nohakostudios.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Wilhansen Li committed Aug 21, 2009 at 22:24 UTC 0ded47581aa6097f1a685443d3c2fc0cebaf8c3c
2 files changed +53 -6
Documentation/git-instaweb.txt
+1 -1
@@ -29,7 +29,7 @@ OPTIONS
29 The HTTP daemon command-line that will be executed.
30 Command-line options may be specified here, and the
31 configuration file will be added at the end of the command-line.
32 - Currently lighttpd, apache2 and webrick are supported.
32 + Currently apache2, lighttpd, mongoose and webrick are supported.
33 (Default: lighttpd)
34
35 -m::
git-instaweb.sh
+52 -5
@@ -77,11 +77,30 @@ start_httpd () {
77 resolve_full_httpd
78
79 # don't quote $full_httpd, there can be arguments to it (-f)
80 - $full_httpd "$fqgitdir/gitweb/httpd.conf"
81 - if test $? != 0; then
82 - echo "Could not execute http daemon $httpd."
83 - exit 1
84 - fi
80 + case "$httpd" in
81 + *mongoose*)
82 + #The mongoose server doesn't have a daemon mode so we'll have to fork it
83 + $full_httpd "$fqgitdir/gitweb/httpd.conf" &
84 + #Save the pid before doing anything else (we'll print it later)
85 + pid=$!
86 +
87 + if test $? != 0; then
88 + echo "Could not execute http daemon $httpd."
89 + exit 1
90 + fi
91 +
92 + cat > "$fqgitdir/pid" <<EOF
93 +$pid
94 +EOF
95 + ;;
96 + *)
97 + $full_httpd "$fqgitdir/gitweb/httpd.conf"
98 + if test $? != 0; then
99 + echo "Could not execute http daemon $httpd."
100 + exit 1
101 + fi
102 + ;;
103 + esac
104 }
105
106 stop_httpd () {
@@ -308,6 +327,31 @@ EOF
327 fi
328 }
329
330 +mongoose_conf() {
331 + cat > "$conf" <<EOF
332 +# Mongoose web server configuration file.
333 +# Lines starting with '#' and empty lines are ignored.
334 +# For detailed description of every option, visit
335 +# http://code.google.com/p/mongoose/wiki/MongooseManual
336 +
337 +root $fqgitdir/gitweb
338 +ports $port
339 +index_files gitweb.cgi
340 +#ssl_cert $fqgitdir/gitweb/ssl_cert.pem
341 +error_log $fqgitdir/gitweb/error.log
342 +access_log $fqgitdir/gitweb/access.log
343 +
344 +#cgi setup
345 +cgi_env PATH=/usr/local/bin:/usr/bin:/bin,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH
346 +cgi_interp $PERL
347 +cgi_ext cgi,pl
348 +
349 +# mimetype mapping
350 +mime_types .gz=application/x-gzip,.tar.gz=application/x-tgz,.tgz=application/x-tgz,.tar=application/x-tar,.zip=application/zip,.gif=image/gif,.jpg=image/jpeg,.jpeg=image/jpeg,.png=image/png,.css=text/css,.html=text/html,.htm=text/html,.js=text/javascript,.c=text/plain,.cpp=text/plain,.log=text/plain,.conf=text/plain,.text=text/plain,.txt=text/plain,.dtd=text/xml,.bz2=application/x-bzip,.tbz=application/x-bzip-compressed-tar,.tar.bz2=application/x-bzip-compressed-tar
351 +EOF
352 +}
353 +
354 +
355 script='
356 s#^(my|our) \$projectroot =.*#$1 \$projectroot = "'$(dirname "$fqgitdir")'";#;
357 s#(my|our) \$gitbin =.*#$1 \$gitbin = "'$GIT_EXEC_PATH'";#;
@@ -344,6 +388,9 @@ case "$httpd" in
388 webrick)
389 webrick_conf
390 ;;
391 +*mongoose*)
392 + mongoose_conf
393 + ;;
394 *)
395 echo "Unknown httpd specified: $httpd"
396 exit 1