Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
winton committed Apr 18, 2010
1 parent 31290fc commit fb8a550
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/with_pid.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@
require 'erb' require 'erb'


def with_pid(options) def with_pid(options)
# Add pid_dir option
options[:pid_dir] = File.dirname(options[:pid]) options[:pid_dir] = File.dirname(options[:pid])

# Render bash script
template = File.dirname(__FILE__) + '/../templates/bash.erb' template = File.dirname(__FILE__) + '/../templates/bash.erb'
template = File.expand_path(template) template = File.expand_path(template)
template = File.read(template) template = File.read(template)
template = ERB.new(template).result(binding) template = ERB.new(template).result(binding)
bash_path = options[:tmp] + "/" + options[:name] bash_path = options[:tmp] + "/" + options[:name]

# Write bash script to tmp
FileUtils.mkdir_p(options[:tmp]) FileUtils.mkdir_p(options[:tmp])
File.open(bash_path, 'w') do |f| File.open(bash_path, 'w') do |f|
f.write(template) f.write(template)
end end

# Execute bash script
`chmod +x #{bash_path}` `chmod +x #{bash_path}`
`#{bash_path}` `#{bash_path}`
end end

0 comments on commit fb8a550

Please sign in to comment.