Ruby on Rails Sunday, April 1, 2012

I have a rake file below that forks some processes, but it seems like
it has more processes than I'd expect, yet it only starts one rails
server. I guess I may try to move the fork() calls into a seperate
module

#

def Kernel.is_windows?
processor, platform, *rest = RUBY_PLATFORM.split("-")
['mswin32','mingw32'].include?(platform)
end

if Kernel.is_windows?
require 'win32/process'
end

require 'faye'

def dbg(msg)
puts msg + ':' + Process.pid.to_s
end

task :start_processes do

dbg('main')
puts "Start Rails Server .. "
exec('rails server') if Process.fork == nil

sleep 15
puts 'Start event machine port service'
dbg('main/EM')
exec 'ruby lib/update_map_svc.rb' if Process.fork == nil

sleep 5
dbg('main/v')
puts 'Start vehicle engine'
exec 'rails runner lib/vehicle-eng.rb' if Process.fork == nil

Process.wait
dbg('after main/v')
end


====================

main:6288
Start Rails Server ..
Start event machine port service
main/EM:6288
main/v:6288
Start vehicle engine
main:3128
Start Rails Server ..
main:6304
Start Rails Server ..
main:6960
Start Rails Server ..
Start event machine port service
main/EM:6304
=> Booting WEBrick
=> Rails 3.2.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Start event machine port service
main/EM:6960
main/v:6960
Start vehicle engine
[2012-04-01 10:51:40] INFO WEBrick 1.3.1
[2012-04-01 10:51:40] INFO ruby 1.9.2 (2011-07-09) [i386-mingw32]
[2012-04-01 10:51:40] INFO WEBrick::HTTPServer#start: pid=6516
port=3000
running Vehicle engine ..

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

No comments:

Post a Comment