Class: Rails::MongrelServer::Stop

Inherits:
Object
  • Object
show all
Includes:
Mongrel::Command::Base
Defined in:
lib/rails/mongrel_server/commands.rb

Instance Method Summary collapse

Instance Method Details

#configureObject



283
284
285
286
287
288
289
290
# File 'lib/rails/mongrel_server/commands.rb', line 283

def configure
  options [
    ['-c', '--chdir PATH', "Change to dir before starting (will be expanded).", :@cwd, "."],
    ['-f', '--force', "Force the shutdown (kill -9).", :@force, false],
    ['-w', '--wait SECONDS', "Wait SECONDS before forcing shutdown", :@wait, "0"],
    ['-P', '--pid FILE', "Where the PID file is located.", :@pid_file, "log/mongrel.pid"]
  ]
end

#runObject



302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/rails/mongrel_server/commands.rb', line 302

def run
  if @force
    @wait.to_i.times do |waiting|
      exit(0) if not File.exist? @pid_file
      sleep 1
    end

    Mongrel::send_signal("KILL", @pid_file) if File.exist? @pid_file
  else
    Mongrel::send_signal("TERM", @pid_file)
  end
end

#validateObject



292
293
294
295
296
297
298
299
300
# File 'lib/rails/mongrel_server/commands.rb', line 292

def validate
  @cwd = File.expand_path(@cwd)
  valid_dir? @cwd, "Invalid path to change to during daemon mode: #@cwd"

  Dir.chdir @cwd

  valid_exists? @pid_file, "PID file #@pid_file does not exist.  Not running?"
  return @valid
end