Hi, I’ve coded a Ruby server listening in TCP and UDP. For TCP I use
GServer
and for UDP an own code.
I need to daemonize it to get it working in background so I can manage
the
service using a Debian init script, but I have no idea of how to do it.
Basically I run the following:
tcp_server = GServer.new(bind_port, bind_ip)
tcp_server.start
tcp_server.join
So, how could I get the programm running in background?
This is, I must be able tu run the program in a terminal:
./my_server.rb
and leave the same terminal free to use it while the daemon is running.
Thanks a lot for any suggestion.
El Sábado, 13 de Junio de 2009, Iñaki Baz C. escribió:
I need to daemonize it to get it working in background so I can manage the
service using a Debian init script, but I have no idea of how to do it.
I had no luck on my first Google search, but I’ve tryed now eith
keywords
“daemonize ruby” and got two possbile solutions :
- Using “daemons” gem
- Using “fokk” and Process.detach
El Sábado, 13 de Junio de 2009, Iñaki Baz C. escribió:
El Sábado, 13 de Junio de 2009, Iñaki Baz C. escribió:
I need to daemonize it to get it working in background so I can manage
the service using a Debian init script, but I have no idea of how to do
it.
I had no luck on my first Google search, but I’ve tryed now eith keywords
“daemonize ruby” and got two possbile solutions :
- Using “daemons” gem
- Using “fokk” and Process.detach
I wonder why the following code doesn’t work at all:
—daemon1.rb----------------------
#!/usr/bin/env ruby
require ‘daemons’
Daemons.daemonize
loop do
sleep 2
end
I run it (ruby daemon1.rb) and after it I check if there is any ruby
process
running:
ps -ef | grep ruby
but it’s not running ¿?¿?¿
Do I miss something? The above comes in the documentaion of Daemons:
http://daemons.rubyforge.org/
El Sábado, 13 de Junio de 2009, Iñaki Baz C. escribió:
- Using “fokk” and Process.detach
loop do
sleep 2
end
I run it (ruby daemon1.rb) and after it I check if there is any ruby
process running:
ps -ef | grep ruby
but it’s not running ¿?¿?¿
Ups, forget it please, it works
Iñaki Baz C. wrote:
El Sábado, 13 de Junio de 2009, Iñaki Baz C. escribió:
I need to daemonize it to get it working in background so I can manage the
service using a Debian init script, but I have no idea of how to do it.
I had no luck on my first Google search, but I’ve tryed now eith
keywords
“daemonize ruby” and got two possbile solutions :
- Using “daemons” gem
- Using “fokk” and Process.detach
Though I haven’t personally used it, you might want to take a look at
the RobustThread <URL:
SuperJared.com is for sale | HugeDomains> library
for your demonic[sic] needs.
On 2009-06-13, Iñaki Baz C. [email protected] wrote:
I need to daemonize it to get it working in background so I can manage the
service using a Debian init script, but I have no idea of how to do it.
The package ‘daemon’ is intended for this,
http://packages.debian.org/lenny/daemon