LoginSignup
1
0

More than 5 years have passed since last update.

【Ruby】DaemonSpawn小さなサンプルメモ

Posted at

インストール

$ gem install daemon-spawn

サンプルメモ

require 'daemon_spawn'

class MyDeamon < DaemonSpawn::Base
  def start(args)
    p "start"
    sleep(5)
    p "start end"
  end

  def stop
    p "stop"
  end
end

MyDeamon.spawn!({
    :working_dir => "./",
    :pid_file => "./pid.log",
    :log_file => "./daemon.log"
                })

実行

% ruby deamon.rb start
MyDeamon started.
% cat pid.log 
21928
% cat daemon.log 
"start"
"start end"

参考

Rubyのdaemonを手軽に作る - ぱろっと・すたじお http://parrot.hatenadiary.jp/entry/20110804/1312448036

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0