2010-12-31 17 views
2

Ich habe eine Klasse, die derzeit über verzögerte Job ausgeführt wird. Eine der Aufgaben besteht darin, "Rake-Spezifikation" auszuführen und die Ausgabe umzuleiten.Delayed_Job Ausführung Rake nicht umleiten Ausgabe

Ich tue dies als solche:

class Executor 
    def execute_command(cmd, &block) 
    STDOUT.sync = true # That's all it takes... 
    IO.popen(cmd + " 2>&1") do |pipe| # Redirection is performed using operators 
     pipe.sync = true 
     while str = pipe.gets 
     block.call str # This is synchronous! 
     end 
    end 

    return $?.success? 
    end 
end 

jedoch keiner der Ausgabe erscheint und es nicht einmal bewusst, die Unit-Tests korrekt auszuführen.

Capistrano funktioniert und es funktioniert auf OSX. Mein Server ist Ubuntu, auf dem Passenger läuft.

Wer hat irgendwelche Ideen, warum die Ausgabe nicht umleiten würde?

Dank

Ben

Antwort

2

Versuchen ohne STDFDES Umleitung auf cmd hier ist, was ich verwendet, und was ich bekommen.

class Executor 
    def execute_command(cmd, &block) 
    STDOUT.sync = true # That's all it takes... 
    IO.popen(cmd) do |pipe| # Redirection is performed using operators 
     pipe.sync = true 
     while str = pipe.gets 
     block.call str # This is synchronous! 
     end 
    end 

    return $?.success? 
    end 
end 

mit Geprüft:

ex = Executor.new 
ex.execute_command "ps aux" do |str| 
    p str 
end 

Ergebnis:

"USER PID% CPU% MEM VSZ RSS TT STAT SCHRITTE
COMMAND \ n TIME" „mitch 423 3.4 1.0 2750692 159552 ?? S 23Apr12 19: 41.59 /Users/mitch/iTerm.app/Contents/MacOS/iTerm -psn_0_40970 \ n "" _windowserver 90 3.1 1.8 3395124 301576 ?? Ss 20Apr12 75:19. 86 /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Resources/WindowServer -Daemon \ n "" mitch 78896 2.0 0.8 1067248 136088 ?? R Thu03PM 37: 46.59 /Applications/Spotify.app/Contents/MacOS/Spotify -psn_0_4900012 \ n "" mitch 436 1.8 1.0 1063952 169320 ?? S 23Apr12 100: 23,87 /Applications/Skype.app/Contents/MacOS/Skype -psn_0_90134 \ n "