mirror of
https://github.com/git/git
synced 2024-08-28 03:59:25 +00:00
Merge branch 'webrick' of git://git.bogomips.org/git-svn
* 'webrick' of git://git.bogomips.org/git-svn: instaweb: add access+error logging for WEBrick instaweb: minimize moving parts for WEBrick instaweb: fix WEBrick server support
This commit is contained in:
commit
d7d1c79cec
|
@ -57,6 +57,13 @@ resolve_full_httpd () {
|
||||||
httpd_only="${httpd%% *}" # cut on first space
|
httpd_only="${httpd%% *}" # cut on first space
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
|
*webrick*)
|
||||||
|
# server is started by running via generated webrick.rb in
|
||||||
|
# $fqgitdir/gitweb
|
||||||
|
full_httpd="$fqgitdir/gitweb/webrick.rb"
|
||||||
|
httpd_only="${httpd%% *}" # cut on first space
|
||||||
|
return
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
httpd_only="$(echo $httpd | cut -f1 -d' ')"
|
httpd_only="$(echo $httpd | cut -f1 -d' ')"
|
||||||
|
@ -188,40 +195,53 @@ GITWEB_CONFIG="$fqgitdir/gitweb/gitweb_config.perl"
|
||||||
export GIT_EXEC_PATH GIT_DIR GITWEB_CONFIG
|
export GIT_EXEC_PATH GIT_DIR GITWEB_CONFIG
|
||||||
|
|
||||||
webrick_conf () {
|
webrick_conf () {
|
||||||
|
# webrick seems to have no way of passing arbitrary environment
|
||||||
|
# variables to the underlying CGI executable, so we wrap the
|
||||||
|
# actual gitweb.cgi using a shell script to force it
|
||||||
|
wrapper="$fqgitdir/gitweb/$httpd/wrapper.sh"
|
||||||
|
cat > "$wrapper" <<EOF
|
||||||
|
#!/bin/sh
|
||||||
|
# we use this shell script wrapper around the real gitweb.cgi since
|
||||||
|
# there appears to be no other way to pass arbitrary environment variables
|
||||||
|
# into the CGI process
|
||||||
|
GIT_EXEC_PATH=$GIT_EXEC_PATH GIT_DIR=$GIT_DIR GITWEB_CONFIG=$GITWEB_CONFIG
|
||||||
|
export GIT_EXEC_PATH GIT_DIR GITWEB_CONFIG
|
||||||
|
exec $root/gitweb.cgi
|
||||||
|
EOF
|
||||||
|
chmod +x "$wrapper"
|
||||||
|
|
||||||
|
# This assumes _ruby_ is in the user's $PATH. that's _one_
|
||||||
|
# portable way to run ruby, which could be installed anywhere, really.
|
||||||
# generate a standalone server script in $fqgitdir/gitweb.
|
# generate a standalone server script in $fqgitdir/gitweb.
|
||||||
cat >"$fqgitdir/gitweb/$httpd.rb" <<EOF
|
cat >"$fqgitdir/gitweb/$httpd.rb" <<EOF
|
||||||
|
#!/usr/bin/env ruby
|
||||||
require 'webrick'
|
require 'webrick'
|
||||||
require 'yaml'
|
require 'logger'
|
||||||
options = YAML::load_file(ARGV[0])
|
options = {
|
||||||
options[:StartCallback] = proc do
|
:Port => $port,
|
||||||
File.open(options[:PidFile],"w") do |f|
|
:DocumentRoot => "$root",
|
||||||
f.puts Process.pid
|
:Logger => Logger.new('$fqgitdir/gitweb/error.log'),
|
||||||
end
|
:AccessLog => [
|
||||||
end
|
[ Logger.new('$fqgitdir/gitweb/access.log'),
|
||||||
options[:ServerType] = WEBrick::Daemon
|
WEBrick::AccessLog::COMBINED_LOG_FORMAT ]
|
||||||
|
],
|
||||||
|
:DirectoryIndex => ["gitweb.cgi"],
|
||||||
|
:CGIInterpreter => "$wrapper",
|
||||||
|
:StartCallback => lambda do
|
||||||
|
File.open("$fqgitdir/pid", "w") { |f| f.puts Process.pid }
|
||||||
|
end,
|
||||||
|
:ServerType => WEBrick::Daemon,
|
||||||
|
}
|
||||||
|
options[:BindAddress] = '127.0.0.1' if "$local" == "true"
|
||||||
server = WEBrick::HTTPServer.new(options)
|
server = WEBrick::HTTPServer.new(options)
|
||||||
['INT', 'TERM'].each do |signal|
|
['INT', 'TERM'].each do |signal|
|
||||||
trap(signal) {server.shutdown}
|
trap(signal) {server.shutdown}
|
||||||
end
|
end
|
||||||
server.start
|
server.start
|
||||||
EOF
|
EOF
|
||||||
# generate a shell script to invoke the above ruby script,
|
chmod +x "$fqgitdir/gitweb/$httpd.rb"
|
||||||
# which assumes _ruby_ is in the user's $PATH. that's _one_
|
# configuration is embedded in server script file, webrick.rb
|
||||||
# portable way to run ruby, which could be installed anywhere,
|
rm -f "$conf"
|
||||||
# really.
|
|
||||||
cat >"$fqgitdir/gitweb/$httpd" <<EOF
|
|
||||||
#!/bin/sh
|
|
||||||
exec ruby "$fqgitdir/gitweb/$httpd.rb" \$*
|
|
||||||
EOF
|
|
||||||
chmod +x "$fqgitdir/gitweb/$httpd"
|
|
||||||
|
|
||||||
cat >"$conf" <<EOF
|
|
||||||
:Port: $port
|
|
||||||
:DocumentRoot: "$root"
|
|
||||||
:DirectoryIndex: ["gitweb.cgi"]
|
|
||||||
:PidFile: "$fqgitdir/pid"
|
|
||||||
EOF
|
|
||||||
test "$local" = true && echo ':BindAddress: "127.0.0.1"' >> "$conf"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lighttpd_conf () {
|
lighttpd_conf () {
|
||||||
|
|
Loading…
Reference in a new issue