What's the best way to start a background process, that can get accessed later on

旧街凉风 提交于 2019-12-03 08:51:13
pid = Process.fork{exec 'gcalctool'} #don't use 'system' or `executable`
1.upto(10) do |n|
  puts "counting #{n}"
  STDOUT.flush
  sleep 1
end
Process.kill( 'HUP', pid )

There is daemons library that'll help you daemonizing your ruby script. It's used by mongrel.

Also there are some other useful gems described on ruby-toolbox.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!