summaryrefslogtreecommitdiff
path: root/git-instaweb.sh
diff options
context:
space:
mode:
authorLibravatar Eric Wong <normalperson@yhbt.net>2010-08-05 08:35:45 +0000
committerLibravatar Eric Wong <normalperson@yhbt.net>2010-08-05 08:51:26 +0000
commitf46e130439a57ce44708971183adab7e58512b34 (patch)
treef58c47672a5b6f69bb9516d2988f2329318f9c27 /git-instaweb.sh
parentinstaweb: fix WEBrick server support (diff)
downloadtgif-f46e130439a57ce44708971183adab7e58512b34.tar.xz
instaweb: minimize moving parts for WEBrick
Since there are WEBrick configuration settings (including the upcoming AccessLog support) that cannot be represented in YAML and require Ruby anyways, the YAML config file is an unnecessary layer of complexity. Additionally, the shell script wrapper to start WEBrick is unecessary since our generated Ruby script can be made executable in the same manner with /usr/bin/env. Signed-off-by: Eric Wong <normalperson@yhbt.net>
Diffstat (limited to 'git-instaweb.sh')
-rwxr-xr-xgit-instaweb.sh45
1 files changed, 17 insertions, 28 deletions
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 5d4ddc8f58..e69fb74fef 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -58,9 +58,9 @@ resolve_full_httpd () {
return
;;
*webrick*)
- # server is started by running via generated webrick.sh in
+ # server is started by running via generated webrick.rb in
# $fqgitdir/gitweb
- full_httpd="$fqgitdir/gitweb/webrick.sh"
+ full_httpd="$fqgitdir/gitweb/webrick.rb"
httpd_only="${httpd%% *}" # cut on first space
return
;;
@@ -214,39 +214,28 @@ EOF
# portable way to run ruby, which could be installed anywhere, really.
# generate a standalone server script in $fqgitdir/gitweb.
cat >"$fqgitdir/gitweb/$httpd.rb" <<EOF
+#!/usr/bin/env ruby
require 'webrick'
-require 'yaml'
-options = YAML::load_file(ARGV[0])
-options[:StartCallback] = proc do
- File.open(options[:PidFile],"w") do |f|
- f.puts Process.pid
- end
-end
-options[:ServerType] = WEBrick::Daemon
+options = {
+ :Port => $port,
+ :DocumentRoot => "$root",
+ :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.sh" <<EOF
-#!/bin/sh
-exec ruby "$fqgitdir/gitweb/$httpd.rb" \$*
-EOF
- chmod +x "$fqgitdir/gitweb/$httpd.sh"
-
- cat >"$conf" <<EOF
-:Port: $port
-:DocumentRoot: "$root"
-:DirectoryIndex: ["gitweb.cgi"]
-:PidFile: "$fqgitdir/pid"
-:CGIInterpreter: "$wrapper"
-EOF
- test "$local" = true && echo ':BindAddress: "127.0.0.1"' >> "$conf"
+ chmod +x "$fqgitdir/gitweb/$httpd.rb"
+ # configuration is embedded in server script file, webrick.rb
+ rm -f "$conf"
}
lighttpd_conf () {