Giter Club home page Giter Club logo

abricot's Introduction

Abricot

Fast cloud command dispatcher tool with Redis pub/sub.

Abricot was built to run benchmarks on a large amount of machines.

How to use

On each slave:

$ abricot listen

On the master:

$ abricot exec echo hello

Specifying the redis server

Both the slaves and master accept the --redis argument (default is localhost). Example:

$ abricot listen --redis redis://redis-server:port/db

Tagging Slaves

You may tag slaves with multiple tags to allow master to pick which slaves get to execute the job.

$ abricot listen --tags large,ruby

Running a job on the command line

$ abricot exec CMD [ARGS...]

To run a job, you may pass several arguments:

  • -f FILE: Run a script file, which will be uploaded. You may use arbitrary scripts with #!... in the header. Arguments given on the command line are ignored.
  • -n NUM_WORKERS: Run the job on exactly NUM_WORKERS.
  • -t TAG: Run the job only on slaves tagged with TAG.

Running a job programmatically

require 'abricot/master'

@abricot = Abricot::Master.new(:redis => 'redis://localhost/1')

@abricot.exec <<-SCRIPT, :name => "Saying Hello"
  touch /tmp/hello
  sleep 1
  echo "Hello"
SCRIPT

@abricot.exec <<-SCRIPT, :name => "Saying Hello"
#!/usr/bin/env ruby
puts "Hello"
SCRIPT

@abricot.exec "echo", "Hello"

You may pass the following options to exec():

  • :num_workers: How many workers to run the command/script on.
  • :tag: a string to specify which tagged workers to run on.
  • :async: run the job asynchronously.

Killing any jobs

@abricot.kill_all # kill all jobs running
@abricot.kill_all_jobs # kill all jobs that we started on @abricot

Note that a SIGINT (ctrl+c) will trigger a kill_all_jobs. Killing jobs is done by issuing a SIGTERM, and then 2 seconds later, a SIGKILL if the process did not respond to the SIGTERM.

Running a job programmatically (async)

job1 = @abricot.exec "sleep 2", :async => true
job2 = @abricot.exec "sleep 1", :async => true

job1.wait
job2.kill

Running jobs in batches

@abricot.multi do
  @abricot.exec "sleep 2"
  @abricot.exec "sleep 1"
end

Running jobs in batches (async)

multi = @abricot.multi :async => true do
  @abricot.exec "sleep 2"
  @abricot.exec "sleep 1"
end

multi.check_for_failures # returns immediately, raises if any job had a failure
multi.kill # kill all jobs
multi.wait # wait for all jobs

Note that the whole batch will be aborded if one of the command fails, and an exception will be thrown in wait().

Exceptions

You may get the following exceptions when running jobs: Abricot::Master::JobFailure Abricot::Master::NotEnoughSlaves.

License

Abricot is released under LGPLv3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.