X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-instaweb.sh;h=8bfa8a055ccd0c344d595f112b571bb3d6e21c28;hb=9fee24cac87078ae48b5a74ecafaca751f5edfd6;hp=b7342e22c88993756e7beb6582a896087e52a034;hpb=6a7f71d376becc1a5b0357b682dd0c20842104b0;p=git.git diff --git a/git-instaweb.sh b/git-instaweb.sh index b7342e22c..8bfa8a055 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -57,6 +57,13 @@ resolve_full_httpd () { httpd_only="${httpd%% *}" # cut on first space 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 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 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" <"$fqgitdir/gitweb/$httpd.rb" < $port, + :DocumentRoot => "$root", + :Logger => Logger.new('$fqgitdir/gitweb/error.log'), + :AccessLog => [ + [ Logger.new('$fqgitdir/gitweb/access.log'), + 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) ['INT', 'TERM'].each do |signal| trap(signal) {server.shutdown} end server.start EOF - # generate a shell script to invoke the above ruby script, - # which assumes _ruby_ is in the user's $PATH. that's _one_ - # portable way to run ruby, which could be installed anywhere, - # really. - cat >"$fqgitdir/gitweb/$httpd" <"$conf" <> "$conf" + chmod +x "$fqgitdir/gitweb/$httpd.rb" + # configuration is embedded in server script file, webrick.rb + rm -f "$conf" } lighttpd_conf () { @@ -538,12 +558,14 @@ my \$app = builder { # make it runnable as standalone app, # like it would be run via 'plackup' utility -if (__FILE__ eq \$0) { +if (caller) { + return \$app; +} else { require Plack::Runner; my \$runner = Plack::Runner->new(); \$runner->parse_options(qw(--env deployment --port $port), - "$local" ? qw(--host 127.0.0.1) : ()); + "$local" ? qw(--host 127.0.0.1) : ()); \$runner->run(\$app); } __END__ @@ -560,6 +582,8 @@ gitweb_conf() { our \$projectroot = "$(dirname "$fqgitdir")"; our \$git_temp = "$fqgitdir/gitweb/tmp"; our \$projects_list = \$projectroot; + +\$feature{'remote_heads'}{'default'} = [1]; EOF }