diff options
author | zedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-03-12 09:10:01 +0000 |
---|---|---|
committer | zedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-03-12 09:10:01 +0000 |
commit | 170bf19f30bfc227fb2b070999ea617b90573aba (patch) | |
tree | 08d86623fc5e05950b1dcbf647eb9fffcd9d6437 | |
parent | 3b36df3cc82b752e53d8610d90a48db841435b0a (diff) | |
download | unicorn-170bf19f30bfc227fb2b070999ea617b90573aba.tar.gz |
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@103 19e92222-5c0b-0410-8929-a290d50e31e9
-rw-r--r-- | doc/site/src/default.template | 4 | ||||
-rw-r--r-- | projects/mongrel_config/lib/mongrel_config/init.rb | 174 |
2 files changed, 6 insertions, 172 deletions
diff --git a/doc/site/src/default.template b/doc/site/src/default.template index 9ce3f06..a136231 100644 --- a/doc/site/src/default.template +++ b/doc/site/src/default.template @@ -50,10 +50,10 @@ <dd> <h5><a href="{relocatable: news.html}">Mongrel 0.3.10 -- Big Release Day</a></h5> - <p>I normally do lots of little releases rather than large big ones, but this + <p>I normally do frequent little releases, but this release involved lots of little touches all over the entire code base. It now has a ton of features and should have the best Rails support yet. It's - even got <b>GemPlugins</b> to a leve that anyone can use it. Read the + even got <b>GemPlugin</b> to a level that anyone can use it. Read the news for the full scoop. </p> <a href="http://rubyforge.org/frs/?group_id=1306" title="Downloads">Download</a> diff --git a/projects/mongrel_config/lib/mongrel_config/init.rb b/projects/mongrel_config/lib/mongrel_config/init.rb index 47caf19..a7fd4d0 100644 --- a/projects/mongrel_config/lib/mongrel_config/init.rb +++ b/projects/mongrel_config/lib/mongrel_config/init.rb @@ -1,172 +1,5 @@ -require 'mongrel' require 'gem_plugin' -require 'camping' -require 'erb' - -Camping.goes :Configure - -module Configure::Models -end - -module Configure::Controllers - class Index < R '/' - def get - render :show - end - end - - class Start < R '/start' - def get - render :start - end - - def post - @results = `mongrel_rails start -d -p #{input.port} -e #{input.env} -n #{input.num_procs} -a #{input.address}` - render :start_done - end - end - - class Kill < R '/kill/(\w+)' - - def get(signal) - if _running? - @signal = signal.upcase - pid = open($PID_FILE) {|f| f.read } - begin - Process.kill(@signal, pid.to_i) - @results = "Mongrel sent PID #{pid} signal #{@signal}." - rescue - puts "ERROR: #$!" - @results = "Failed to signal the Mongrel process. Maybe it is not running?<p>#$!</p>" - end - else - @results = "Mongrel does not seem to be running. Maybe delete the pid file #{$PID_FILE} or start again." - end - - render :kill - end - end - - - class Stop < R '/stop' - def get - render :stop - end - end - - class Logs < R '/logs' - def get - @log_files = Dir.glob("log/**/*") - render :logs - end - end - -end - - -module Configure::Views - def layout - body_content = yield - currently_running = _running? - pid = _pid - open(GemPlugin::Manager.instance.resource("mongrel_config", "/index.html")) do |f| - template = ERB.new(f.read) - self << template.result(binding) - end - end - - def show - div do - h2 { "Status" } - if _running? - p { "Currently running with PID #{_pid}." } - else - p { "Mongrel is not running." } - end - end - end - - def start - div do - form :action => "/start", :method => "POST" do - p { span { "Port:" }; input :name => "port", :value => "4000" } - p { span { "Environment:" }; input :name => "env", :value => "development" } - p { span { "Address:" }; input :name => "address", :value => "0.0.0.0" } - p { span { "Number Processors:" }; input :name => "num_procs", :value => "20" } - input :type => "submit", :value => "START" - end - end - end - - def start_done - div do - p { @results } - end - end - - def kill - div do - p { @results } - - case @signal - when "HUP": - p { "A reload (HUP) does not stop the process, but may not be complete." } - when "TERM": - p { "Stopped with TERM signal. The process should exit shortly, but only after processing pending requests." } - when "USR2": - p { "Complete restart (USR2) may take a little while. Check status in a few seconds or read logs." } - when "KILL": - p { "Process was violently stopped (KILL) so pending requests will be lost." } - end - end - end - - def stop - if _running? - ul do - li { a "Stop (TERM)", :href => "/kill/term" } - li { a "Reload (HUP)", :href => "/kill/hup" } - li { a "Restart (USR2)", :href => "/kill/usr2" } - li { a "Kill (KILL)", :href => "/kill/kill" } - end - else - p { "Mongrel does not appear to be running (no PID file at #$PID_FILE)." } - end - end - - def logs - div do - h2 { "Logs" } - table do - tr do - th { "File"}; th { "Bytes" }; th { "Last Modified" } - end - @log_files.each do |file| - tr do - td { a file, :href => "../#{file}" } - td { File.size file } - td { File.mtime file } - end - end - end - end - end - - def _running? - File.exist? $PID_FILE - end - - def _pid - open($PID_FILE) {|f| f.read } if _running? - end -end - -def Configure.create - unless Configure::Models::Setting.table_exists? - ActiveRecord::Schema.define(&Configure::Models.schema) - Configure::Models::Setting.reset_column_information - end -end +require 'mongrel' class ConfigTool < GemPlugin::Plugin "/commands" @@ -196,8 +29,10 @@ class ConfigTool < GemPlugin::Plugin "/commands" def run - require 'mongrel/camping' + # must require this here since rails and camping don't like eachother + require 'mongrel_config/app' + resources = GemPlugin::Manager.instance.resource "mongrel_config", "/" $PID_FILE = @pid_file $server = Mongrel::Camping::start(@host,@port,@uri,Configure) @@ -214,7 +49,6 @@ class ConfigTool < GemPlugin::Plugin "/commands" # add our log directory $server.register("/log", Mongrel::DirHandler.new("log")) - resources = GemPlugin::Manager.instance.resource "mongrel_config", "/" $server.register("/config/resources", Mongrel::DirHandler.new(resources)) $server.acceptor.join |