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 !!?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.