Background option like script/server -d has


#1

Hi. I’m curious to know how I can type something like the following:

$ ruby my_program.rb

Press enter, and gain immediate control of the terminal again, as
happens when you supply the -d option when running the script/server
command from inside a Rails app.

Any ideas?


#2

Hi. I’m curious to know how I can type something like the following:

$ ruby my_program.rb

Press enter, and gain immediate control of the terminal again, as
happens when you supply the -d option when running the script/server
command from inside a Rails app.

Any ideas?

The ‘daemons’ library may help
http://rubyforge.org/projects/daemons/

require ‘daemons’
Daemons.run_proc(‘a string for identifier’) do
…your code
end

saji


Posted via http://www.ruby-forum.com/.


Saji N. Hameed

APEC Climate Center +82 51 668 7470
National Pension Corporation Busan Building 12F
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705 removed_email_address@domain.invalid
KOREA


#3

Saji N. Hameed wrote:

The ‘daemons’ library may help
http://rubyforge.org/projects/daemons/

That’s exactly what I need, thank you Saji. :slight_smile: