Manage pid file when run a rake task
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
lib
test
.gitignore
Gemfile
LICENSE.txt
README.md
Rakefile
rake_pid.gemspec initial commit Dec 16, 2012

README.md

RakePid

RakePid is use to write a pid file when you run a rask task, and auto delete pid file when task is end or abort. It was useful when you need to monitor your rake task with monit or god.

Installation

Add this line to your application's Gemfile:

gem 'rake_pid'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rake_pid

Usage

Configure the directory

If no directory be configured, RakePid would write pid file to current directory.

  RakePid.configure do
    path 'tmp/pids'
  end

Write rake task

  task :hello do |task|
    with_pid(task) do
      puts "world"
    end
  end

Override pid file name

You can override pid file name by set PIDFILE

  rake hello PIDFILE=foo.pid

Your can force delete pid file if something is going wrong by set FORCE to true

  rake hello FORCE=true

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request