File: ctrl_proc_rand.rb

package info (click to toggle)
ruby-daemons 1.4.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 388 kB
  • sloc: ruby: 2,133; makefile: 7
file content (21 lines) | stat: -rw-r--r-- 577 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))

if File.exist?(File.join(lib_dir, 'daemons.rb'))
  $LOAD_PATH.unshift lib_dir
else
  begin; require 'rubygems'; rescue ::Exception; end
end

require 'daemons'

Daemons.run_proc('myscript') do
  loop do
    file = File.open('/tmp/myscript.log', 'a')
    file.write(Random.rand)   # breaks without seeding
    # file.write(Random.new.rand)  # works without seeding
    # file.write(rand) # also works, but this is Kernel.rand() so its different
    file.write("\n")
    file.close
    sleep 2
  end
end