[Backgroundrb-devel] strange problem with system call

Ezra Zygmuntowicz ezmobius at gmail.com
Mon Aug 21 11:38:34 EDT 2006


	Yeah Charles has the right idea. One other way to do what you want  
would be to kill the process directly by running

pid = `ps axww | grep -v grep | grep typo`  # or whatever the process  
is called?

then get the pid out of that text and do a kill -9 on it. But I think  
you are probably better off with a popen solution. I am going to be  
redoing the start scripts to use the daemons gem which might fix this  
problem.

-Ezra

On Aug 21, 2006, at 8:29 AM, Charles Brian Quinn wrote:

> Many times those calls to start/stop scripts get backgrounded, so it
> could actually be returning instantly.  You could try wrapping it, or
> go check what typo stop is actually doing and make sure there's no
> "blah blah &" in the script.
>
> You could also try using popen and popen3 processes instead of the
> `command` backticks.  I find those hard to debug as you don't know
> what's going on when they run.
>
> This will allow you to see stdin, stderr, and stdout on the  
> process.  Sample:
>
> cmd_to_run = "typo stop"
>
>        stdin, stdout, stderr = Open3.popen3(cmd_to_run)
>
>        s_stderr = stderr.read.to_s
>        s_stdout = stdout.read.to_s
>
>        # if you'd like to see it
>        logger.info "stdout: #{s_stdout}"
>        logger.info "stderr: #{s_stderr}"
>
>        if s_stderr.empty? && s_stdout.starts_with?("error stuff here")
>          return true
>        else
>          errors.add_to_base("error msg here")
>          return false
>        end
>
> hope that helps!
>
> On 8/21/06, hemant <gethemant at gmail.com> wrote:
>> Hi,
>>
>> I am using backgroundrb to create a automated system of typo  
>> blogs.So, users
>> can create new typo applications using web interface and all that  
>> jazz.
>>
>> Now..its working perfectly except one minor glitch. Since latest  
>> version of
>> typo has a command called "typo", i simply use that command to  
>> install new
>> typo app.And it works.
>>
>> def do_work(args)
>>     DIR = "/home/foobar/public_html"
>>     username = args
>>     blog_name = username + "_blog"
>>      # creation part works flawlessly so lets skip that.
>>     # there is a problem while stopping it.
>>     if (Dir.chdir(DIR)) == 0
>>           current_dir = `pwd`
>>           @logger.debug("Current directory is #{current_dir}")
>>           stop_command = "typo stop "+ blog_name
>>           debug_stuff = `#{stop_command}`
>>                                               #line no 33
>>           @logger.debug("### #{debug_stuff}")
>>     else
>>       @logger.debug("### Error changing directory")
>>     end
>> end
>> Now let me assure that, args has correct username, because  
>> starting of
>> blog,migrating from sqlite to mysql works perfectly using this worker
>> thread.The only glitch is, in line # 33, "typo stop " doesn't  
>> work.I have
>> tried system also.system returns true, so typo should be  
>> stopped.But when i
>> do "ps aux|grep foobar" , it isn't ,process is still there.
>>
>> When i tried `command`. All i got in debug_stuff variable is a empty
>> string.However, when i try same stuff from irb, it works as  
>> expected and
>> typo stopped.Now..again let me assure that, the worker thread IS  
>> getting
>> CALLED.
>>
>> I have tried various stuff.But since, I am simply not able to  
>> debug, where
>> the heck problem is, I am lost. I was told that, system or  
>> `command` both
>> wait for the command to finish execution to resume normal  
>> execution.But for
>> me it SEEMS that the call to "typo stop #{blog_name}" returns  
>> immediately.
>>
>>
>>
>>
>> _______________________________________________
>> Backgroundrb-devel mailing list
>> Backgroundrb-devel at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/backgroundrb-devel
>>
>>
>
>
> -- 
> Charles Brian Quinn
> self-promotion: www.seebq.com
> highgroove studios: www.highgroove.com
> slingshot hosting: www.slingshothosting.com
> _______________________________________________
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel



More information about the Backgroundrb-devel mailing list