これは、開発マシンとテスト用です。サーバーを起動するスクリプトを起動しようとしていますが、出力が条件を満たすと無視されます。処理が終わらないのでバッククォートが使えません。私は-QUIT
独立してプロセスを実行します (スクリプトの別の場所)。これまでのところ、これは私が持っている最も近いものです:
require "pty"
catch :ready do
begin
PTY.spawn( "bin/start" ) do |stdin, stdout, pid|
begin
stdin.each { |line|
throw(:ready) if line['worker ready']
}
rescue Errno::EIO
puts "no more output"
end
end
rescue PTY::ChildExited
puts "child process exit"
end
end # === end of catch block
# Continue with the rest of the script...
これまでのところ動作しますが、Ruby とプロセスは初めてです。私がオンラインで見た他のすべてのソリューションには、パイプ、フォーク、およびProcess.detach
. throw
にいる間に使用して何か悪いことをしていPTY.spawn
ますか?