31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/main/daemon.rb', line 31
def setup!
@dotdir = @main.dotdir
@dirname = File.expand_path(File.dirname(@script))
@basename = File.basename(@script)
@script_dir = File.expand_path(File.dirname(@script))
@daemon_dir = File.join(@dotdir, 'daemon')
@lock_file = File.join(@daemon_dir, 'lock')
@log_file = File.join(@daemon_dir, 'log')
@pid_file = File.join(@daemon_dir, 'pid')
@stdin_file = File.join(@daemon_dir, 'stdin')
@stdout_file = File.join(@daemon_dir, 'stdout')
@stderr_file = File.join(@daemon_dir, 'stderr')
FileUtils.mkdir_p(@daemon_dir) rescue nil
%w( lock log pid stdin stdout stderr ).each do |which|
file = instance_variable_get("@#{ which }_file")
FileUtils.touch(file)
end
@started_at = Time.now
@ppid = Process.pid
STDOUT.sync = true
STDERR.sync = true
self
end
|