Permalink
Browse files

Comments

  • Loading branch information...
1 parent 31290fc commit fb8a550f0a0b3d583428c6ef635ebdb570961f41 @winton committed Apr 18, 2010
Showing with 7 additions and 0 deletions.
  1. +7 −0 lib/with_pid.rb
View
7 lib/with_pid.rb
@@ -2,16 +2,23 @@
require 'erb'
def with_pid(options)
+ # Add pid_dir option
options[:pid_dir] = File.dirname(options[:pid])
+
+ # Render bash script
template = File.dirname(__FILE__) + '/../templates/bash.erb'
template = File.expand_path(template)
template = File.read(template)
template = ERB.new(template).result(binding)
bash_path = options[:tmp] + "/" + options[:name]
+
+ # Write bash script to tmp
FileUtils.mkdir_p(options[:tmp])
File.open(bash_path, 'w') do |f|
f.write(template)
end
+
+ # Execute bash script
`chmod +x #{bash_path}`
`#{bash_path}`
end

0 comments on commit fb8a550

Please sign in to comment.