nginx does not support regular CGI
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
Makefile | 5 +++-
git-instaweb.sh | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 75 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 3e94def..893c7f2 100644
--- a/Makefile
+++ b/Makefile
@@ -690,7 +690,8 @@ gitweb/gitweb.fcgi: gitweb/gitweb-fcgi.perl
chmod +x $@+
mv $@+ $@
-git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
+git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css \
+ gitweb/gitweb.fcgi
rm -f $@ $@+
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
@@ -699,6 +700,8 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
-e '/@@GITWEB_CGI@@/d' \
-e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
-e '/@@GITWEB_CSS@@/d' \
+ -e '/@@GITWEB_FCGI@@/r gitweb/gitweb.fcgi' \
+ -e '/@@GITWEB_FCGI@@/d' \
$@.sh > $@+
chmod +x $@+
mv $@+ $@
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 08362f4..dcd04fd 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -20,7 +20,7 @@ httpd="`git repo-config --get instaweb.httpd`"
browser="`git repo-config --get instaweb.browser`"
port=`git repo-config --get instaweb.port`
module_path="`git repo-config --get instaweb.modulepath`"
-
+fcgi_pid_file="$fqgitdir"/gitweb/fcgi.pid
conf=$GIT_DIR/gitweb/httpd.conf
# Defaults:
@@ -34,7 +34,22 @@ test -z "$browser" && browser='firefox'
# any untaken local port will do...
test -z "$port" && port=1234
+use_fcgi () {
+ case "$httpd" in
+ *nginx*)
+ return 0
+ ;;
+ esac
+ return -1
+}
+
start_httpd () {
+ if use_fcgi; then
+ "$fqgitdir"/gitweb/gitweb.fcgi \
+ --fcgi-socket="$fcgi_sock" \
+ --cgi-bin="$fqgitdir/gitweb/gitweb.cgi" &
+ echo $! > "$fcgi_pid_file"
+ fi
httpd_only="`echo $httpd | cut -f1 -d' '`"
if test "`expr index $httpd_only /`" -eq '1' || \
which $httpd_only >/dev/null
@@ -61,6 +76,9 @@ start_httpd () {
}
stop_httpd () {
+ if use_fcgi; then
+ test -f "$fcgi_pid_file" && kill `cat "$fcgi_pid_file"`
+ fi
test -f "$fqgitdir/pid" && kill `cat "$fqgitdir/pid"`
}
@@ -138,7 +156,48 @@ mkdir -p "$GIT_DIR/gitweb/tmp"
GIT_EXEC_PATH="`git --exec-path`"
GIT_DIR="$fqgitdir"
export GIT_EXEC_PATH GIT_DIR
+fcgi_sock="$fqgitdir/gitweb/fcgi.sock"
+nginx_conf () {
+ mkdir -p "$fqgitdir"/gitweb/logs
+ cat > "$conf" <<EOF
+pid $fqgitdir/pid;
+error_log $fqgitdir/gitweb/logs/error.log;
+events {
+ worker_connections 1024;
+}
+http {
+ access_log $fqgitdir/gitweb/logs/access.log;
+ types {
+ text/css css;
+ }
+ server {
+ listen $port;
+ root $fqgitdir/gitweb;
+ location = / {
+ fastcgi_pass unix:$fcgi_sock;
+ fastcgi_index gitweb.fcgi;
+ fastcgi_param QUERY_STRING \$query_string;
+ fastcgi_param REQUEST_METHOD \$request_method;
+ fastcgi_param CONTENT_TYPE \$content_type;
+ fastcgi_param CONTENT_LENGTH \$content_length;
+ fastcgi_param SCRIPT_NAME \$fastcgi_script_name;
+ fastcgi_param REQUEST_URI \$request_uri;
+ fastcgi_param DOCUMENT_URI \$document_uri;
+ fastcgi_param DOCUMENT_ROOT \$document_root;
+ fastcgi_param SERVER_PROTOCOL \$server_protocol;
+ fastcgi_param GATEWAY_INTERFACE CGI/1.1;
+ fastcgi_param SERVER_SOFTWARE nginx;
+ fastcgi_param REMOTE_ADDR \$remote_addr;
+ fastcgi_param REMOTE_PORT \$remote_port;
+ fastcgi_param SERVER_ADDR \$server_addr;
+ fastcgi_param SERVER_PORT \$server_port;
+ fastcgi_param SERVER_NAME \$server_name;
+ }
+ }
+}
+EOF
+}
lighttpd_conf () {
cat > "$conf" <<EOF
@@ -230,8 +289,16 @@ gitweb_css () {
EOFGITWEB
}
+gitweb_fcgi () {
+ cat > "$1" <<\EOFGITWEB
+@@GITWEB_FCGI@@
+EOFGITWEB
+ chmod +x "$1"
+}
+
gitweb_cgi $GIT_DIR/gitweb/gitweb.cgi
gitweb_css $GIT_DIR/gitweb/gitweb.css
+gitweb_fcgi $GIT_DIR/gitweb/gitweb.fcgi
case "$httpd" in
*lighttpd*)
@@ -240,6 +307,9 @@ case "$httpd" in
*apache2*)
apache2_conf
;;
+*nginx*)
+ nginx_conf
+ ;;
*)
echo "Unknown httpd specified: $httpd"
exit 1
--
1.5.0.rc0.gcafca-dirty
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Linus Torvalds | Re: O_DIRECT question |
| Bryan Woods | Stardom SATA HSM violation |
| Dave Airlie | Re: [2.6.25-rc6] possible regression: X server dying |
git: | |
| Petr Baudis | repo.or.cz wishes? |
| Linus Torvalds | Re: empty directories |
| Wink Saville | Resolving conflicts |
| Jon Smirl | ! [rejected] master -> master (non-fast forward) |
| Richard Stallman | Real men don't attack straw men |
| Christophe Rioux | OpenBSD as host for VMWare Server |
| Stefan Beke | mail dovecot: pipe() failed: Too many open files |
| Jason Dixon | Re: OBSD on MacBook |
| Auke Kok | [PATCH] e1000e: test MSI interrupts |
| Andrew Morton | drivers/net/r6040.c warnings on x86_64 |
| Wei Yongjun | [PATCH] xfrm: Fix kernel panic when flush and dump SPD entries |
| Леонид Юрьев | [r8169] patch for RTL8102 (5 new MAC/PHY) |
