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>
This commit is contained in:
Eric Wong 2010-08-05 08:35:45 +00:00
Родитель 422bff2802
Коммит f46e130439
1 изменённых файлов: 17 добавлений и 28 удалений

Просмотреть файл

@ -58,9 +58,9 @@ resolve_full_httpd () {
return return
;; ;;
*webrick*) *webrick*)
# server is started by running via generated webrick.sh in # server is started by running via generated webrick.rb in
# $fqgitdir/gitweb # $fqgitdir/gitweb
full_httpd="$fqgitdir/gitweb/webrick.sh" full_httpd="$fqgitdir/gitweb/webrick.rb"
httpd_only="${httpd%% *}" # cut on first space httpd_only="${httpd%% *}" # cut on first space
return return
;; ;;
@ -214,39 +214,28 @@ EOF
# portable way to run ruby, which could be installed anywhere, really. # 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' options = {
options = YAML::load_file(ARGV[0]) :Port => $port,
options[:StartCallback] = proc do :DocumentRoot => "$root",
File.open(options[:PidFile],"w") do |f| :DirectoryIndex => ["gitweb.cgi"],
f.puts Process.pid :CGIInterpreter => "$wrapper",
end :StartCallback => lambda do
end File.open("$fqgitdir/pid", "w") { |f| f.puts Process.pid }
options[:ServerType] = WEBrick::Daemon 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.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"
} }
lighttpd_conf () { lighttpd_conf () {