Skip to content

Instantly share code, notes, and snippets.

@fbehrens
Created August 5, 2010 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbehrens/509423 to your computer and use it in GitHub Desktop.
Save fbehrens/509423 to your computer and use it in GitHub Desktop.
process commands with pid file
#rakefile
require 'rake'
extend FileUtils
PID = '.pid'
task :default => :reset
module Kernel
def pid
raise "pid file already exists" if File.exists? PID
touch PID
yield
rm PID
end
end
desc "deletes PID file"
task :reset do
rm PID
end
desc "invokes my awkyard command"
task :short do
pid do
system 'ls'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment