What is the best way to start a background process that can be accessed later

I am currently developing RubyGem that provides an executable. The executable file monitors the status of some log files using the FSSM gem.

This executable should start, do something in the background and stop later.

For instance:

$ my_executable start
# do something different...
$ my_executable stop

First, I would start a new process that makes a file that looks through the material at the beginning of the method. But I do not know how to solve this process to stop it.

What is the best way to ensure this behavior?

Yours faithfully

+3
source share
2 answers
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 )
+3
source

daemons , ruby ​​script. mongrel.

, ruby-toolbox.

0

Source: https://habr.com/ru/post/1761796/


All Articles