41

I'm writing a ruby bootstrapping script for a school project, and part of this bootstrapping process is to start a couple of background processes (which are written and function properly). What I'd like to do is something along the lines of:

`/path/to/daemon1 &`
`/path/to/daemon2 &`
`/path/to/daemon3 &`

However, that blocks on the first call to execute daemon1. I've seen references to a Process.spawn method, but that seems to be a 1.9+ feature, and I'm limited to Ruby 1.8.

I've also tried to execute these daemons from different threads, but I'd like my bootstrap script to be able to exit.

So how can I start these background processes so that my bootstrap script doesn't block and can exit (but still have the daemons running in the background)?

4

2 に答える 2

1

疑似デーモン化するより良い方法:

`((/path/to/deamon1 &)&)` 

プロセスを独自のシェルにドロップします。

実際にデーモン化する最良の方法:

`service daemon1 start`

サーバー/ユーザーが実際のデーモンを開始する権限を持っていることを確認してください。Linux 用の「deamonize」ツールをチェックして、デーモンを設定してください。

于 2017-02-18T00:55:58.520 に答える