1

I have a TCPclient written on Ruby. I want to use it in background. Currently it has a loop:

loop do
end

So i can run a client, and it works forever.

Is there a way to run in as a service, and write a pid to file, then i'll able to kill that process by pid?

Alex
  • 2,309
  • 2
  • 16
  • 20

2 Answers2

6

The daemons gem is made just for this.

x1a4
  • 19,417
  • 5
  • 40
  • 40
0

You can use the unix system for that :

ruby myfile.rb && echo $! > my_file.pid
shingara
  • 46,608
  • 11
  • 99
  • 105