how to start/stop server

hi, i'm a new user of ROR, and i find some probleme to manipulate threads. so, i have two ROR app runing in m computer,the first is for exemple Diaspora* and the second the app that im writing to administrate Diaspora server. so i want from the adminstration panel, start/stop Diaspora server. i wrote this:

class AdministrationController < ApplicationController

  def index

    render :layout => 'test'   end

  def statuts

    io = IO.popen("lsof -i :1234 | awk '{print $2}'")      output = io.read      io.close

    if output == ''       flash[:notice] = 'server down'     else       flash[:notice] = 'server up '     end     redirect_to :action => :index

  end

  def start_serv     @test= Thread.new do     io = IO.popen("cd /home/delmed/diaspora/ && ./script/server")     @output = io.read     io.close     end     sleep 5     self.statuts     flash[:notice] = 'server up '   end

  def kill_serv     io = IO.popen("netstat -tanp | grep 1234 | awk '{print $7}'")     @output = io.read     io.close

    io = IO.popen("kill -9 #{@output[0..3]}")     output = io.read     io.close

    io = IO.popen("netstat -tanp | grep 8080 | awk '{print $7}'")     @output = io.read     io.close

    io = IO.popen("kill -9 #{@output[0..3]}")     output = io.read     io.close     self.statuts end

end

like you see, the start_serv method create a thread to run the diaspora server. but in the kill_serv (stop diaspora server) i cant recover this thread to kill or stop. what can i do please !!?