6 my_path=File.dirname(__FILE__)
8 # start zyn, grep the lo server port, and connect the port checker to it
9 # NOTE: If you add too much debug output to zyn, it will be blocked when writing into the pipe,
10 # leading to MiddleWare to not reply and to port-checker to fail.
11 # This script should be rewritten to keep reading (and printing) zyn's messages.
12 Open3.popen3(my_path + "/../zynaddsubfx -O null --no-gui") do |stdin, stdout, stderr, wait_thr|
14 while line=stderr.gets do
15 # print "line: " + line;
16 if /^lo server running on (\d+)$/.match(line) then
17 sleep 3 # give zyn more time to setup
18 port_checker_rval = system(my_path + "/../../rtosc/port-checker 'osc.udp://localhost:" + $1 + "/'")
19 if port_checker_rval != true then
20 puts "Error: port-checker has returned #{$?.exitstatus}."
24 # Check if zyn has not crashed yet
25 # Wait 1 second before detection
28 # This is only executed if Process.kill did not raise an exception
29 Process.kill("KILL", pid)
31 puts "Error: ZynAddSubFX (PID #{pid}) crashed!"
32 puts " Missing replies or port-checker crashes could be due to the crash."
35 puts "Error: Cannot kill ZynAddSubFX (PID #{pid})?"