Acacia Acacia - 3 months ago 10
Ruby Question

Ruby TCP server closes

I have a TCP server I start with the following command;

nohup ruby ./server.rb &


However, after a couple of days, this process is just closed and cannot trace the point when it breaks,

How do i keep the TCP server alive for ever until stopped.

Answer

You should wrap your process in a daemon handler so it gets restarted automatically.

You make a launcher script called something like launcher.rb that looks like this:

require 'daemons'

Daemons.run('myserver.rb')

Then, as per the documentation:

ruby launcher.rb start
Comments