项目作者: haines

项目描述 :
Capture log output from Rake multitasks
高级语言: Ruby
项目地址: git://github.com/haines/rake-multilogs.git
创建时间: 2018-06-08T08:23:18Z
项目社区:https://github.com/haines/rake-multilogs

开源协议:MIT License

下载


Rake::Multilogs

Docs
Gem
GitHub
License
Travis

Rake multitask logs can be confusing, with output from each of the concurrently-running tasks being interleaved.
Rake::Multilogs untangles the mess by capturing each task’s output and displaying it after all the tasks are finished.

Installation

Add this line to your application’s Gemfile:

  1. gem "rake-multilogs"

And then execute:

  1. $ bundle install

Or install it yourself as:

  1. $ gem install rake-multilogs

JRuby and Windows are not supported, because Process.fork is unavailable.
Rake::Multilogs will gracefully fall back to the default (interleaved) output on those platforms.

Usage

Add this line to your application’s Rakefile:

  1. require "rake/multilogs"

Your multitasks will now run concurrently in forked processes, with each task’s output displayed after all tasks have completed.

The use of forking rather than the default threading implementation means that database connections and other resources need to be handled carefully.
You need to make sure each forked process has its own connection by using the before_fork and after_fork hooks.

For example, with Active Record, you can put the following config in your Rakefile:

  1. Rake::Multilogs.before_fork do
  2. ActiveRecord::Base.connection.disconnect!
  3. end
  4. Rake::Multilogs.after_fork do
  5. ActiveRecord::Base.establish_connection
  6. end

Development

After checking out the repo, run bin/setup to install dependencies.
Then, run bin/rake test to run the tests.
You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bin/rake install.
To release a new version, update the version number in lib/rake/multilogs/version.rb, and then run bin/rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to RubyGems.

Contributing

Bug reports and pull requests are welcome on GitHub.
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

© 2018 Andrew Haines, released under the MIT license.