On Tue, May 10, 2011 at 10:54 AM, Colin Law <clan...@googlemail.com> wrote:

> On 10 May 2011 15:45, Alex Katebi <alex.kat...@gmail.com> wrote:
>
> Please don't top post, it makes it difficult to follow the thread.
>
Sure!

> Insert your replies at appropriate points in previous message.  Thanks
>
> > I have restarted the server but not the computer. I am doing something
> > abnormal. Off of a request I start some external program as sub
> processes.
> > It takes about one second to start those sub processes. How long are we
> > allowed to delay the sending of a respond? Is there a better way do this
> in
> > Rails way? This problem is intermittent.
>
> Where are you starting the sub processes?  You said there was nothing
> in the server or application development.log when you do the submit so
> it is not getting as far as a rails action.
>

I meant to say that I started the subprocesses in the previous request.
Here is my code:

class PortalMonitor
  include Mongoid::Document
  field :count, :type => Integer
  field :url, :type => String
  field :user, :type => String
  field :password, :type => String
  field :run, :type => Boolean

  validates_presence_of :count, :url, :user, :password
  validates_uniqueness_of :url

  #embeds_many :emails
  embeds_many :vidyo_desktops

  after_create :desktop_start
  before_destroy :desktop_stop
  before_update :desktop_stop, :desktop_start, :if => :changed?

  def desktop_stop
    t1 = Time.now
    Rails.logger.debug "######### Stop VidyoDesktops size =
#{vidyo_desktops.size} Dir = #{Dir.getwd} #########"
    for vd in vidyo_desktops
      Rails.logger.debug "######## #{vd.vd_pid} ######"
      begin
        Process.kill 'TERM', vd.vd_pid
      rescue Errno::ESRCH
      end
    end
    vidyo_desktops.delete_all
    Rails.logger.debug "############# TIME SPENT STOP #{Time.now - t1}
##################"
  end

  def desktop_start
    Rails.logger.debug "######### desktop_start ###########"
    return if run == false
    t1 = Time.now
    count.times do |n|
      n += 1
      cmd = 'lib/vidyo/VidyoDesktop'
      eid = user + n.to_s
      root = 'lib/vidyo'
      args = " --eid #{eid} --port #{51300+n} " +
        "--video #{root}/ofer_wvga.vidyo --audio #{root}/ogm.wav"
      cmd = cmd.to_s + args
      pid, vd_stdin, vd_stdout, vd_stderr = Open4::popen4(cmd)
      #eval("`#{cmd}&`")
      #pid = $?.pid
=begin
         Thread.new do
          while (( line = vd_stderr.gets ))
            puts "errrrrrrrrrr #{line}"
          end
        end
         Thread.new do
          while (( line = vd_stdout.gets ))
            puts "ottttttttttt #{line}"
          end
        end
=end
      Rails.logger.debug "######### Start VidyoDesktops #{pid} cmd = #{cmd}
#########"
      vidyo_desktops.create!(:vd_pid => pid, :pm_pid => 0, :pm_error =>
"Hello There!")
      Process.detach(pid)
      #p vidyo_desktops
    end
    Rails.logger.debug "############# TIME SPENT START #{Time.now - t1}
##################"
  end


end





> Colin
>
> >
> > On Tue, May 10, 2011 at 10:29 AM, David Kahn <d...@structuralartistry.com>
> > wrote:
> >>
> >>
> >> On Tue, May 10, 2011 at 9:25 AM, Alex Katebi <alex.kat...@gmail.com>
> >> wrote:
> >>>
> >>> I see nothing any where.
> >>
> >> To clarify, on your server terminal window, you see no output when you
> try
> >> to access a page? And of course the page does not load, I assume. It is
> >> probably not this if you are seeing nothing at all on the terminal, but
> >> sometimes if I forget to remove a debugger line and still am running the
> >> server in --debugger mode then of course it hangs.
> >>
> >> Otherwise, other obvious quations: have you restarted the server? As
> well,
> >> restarted your computer?
> >>
> >>>
> >>> On Mon, May 9, 2011 at 4:58 PM, Colin Law <clan...@googlemail.com>
> wrote:
> >>>>
> >>>> On 9 May 2011 21:54, Alex Katebi <alex.kat...@gmail.com> wrote:
> >>>> > If my Rails server has been sitting idle for a while, it does not
> >>>> > respond to
> >>>> > new requests.
> >>>> > What is the best way to troubleshoot something like that.
> >>>> > I am using Rails 3.0.7 in development.
> >>>>
> >>>> Is there anything in development.log when you submit the request (or
> >>>> already there indicating a problem before the request)?  What about in
> >>>> the server terminal window?
> >>>>
> >>>> Colin
> >>>>
> >>>> --
> >>>> 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@googlegroups.com.
> >>>> To unsubscribe from this group, send email to
> >>>> rubyonrails-talk+unsubscr...@googlegroups.com.
> >>>> For more options, visit this group at
> >>>> http://groups.google.com/group/rubyonrails-talk?hl=en.
> >>>>
> >>>
> >>> --
> >>> 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@googlegroups.com
> .
> >>> To unsubscribe from this group, send email to
> >>> rubyonrails-talk+unsubscr...@googlegroups.com.
> >>> For more options, visit this group at
> >>> http://groups.google.com/group/rubyonrails-talk?hl=en.
> >>
> >> --
> >> 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@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> rubyonrails-talk+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >> http://groups.google.com/group/rubyonrails-talk?hl=en.
> >
> > --
> > 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@googlegroups.com.
> > To unsubscribe from this group, send email to
> > rubyonrails-talk+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/rubyonrails-talk?hl=en.
> >
>
> --
> 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@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to