4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/with_pid.rb', line 4
def with_pid(options)
bash_path = options[:tmp] + "/" + options[:name]
options[:pid_dir] = File.dirname(options[:pid])
template = File.dirname(__FILE__) + '/../templates/bash.erb'
template = File.expand_path(template)
template = File.read(template)
template = ERB.new(template).result(binding)
FileUtils.mkdir_p(options[:tmp])
File.open(bash_path, 'w') do |f|
f.write(template)
end
`chmod +x #{bash_path}`
`#{bash_path}`
end
|