Giter Site home page Giter Site logo

cmdstalk's Introduction

cmdstalk

Cmdstalk is a unix-process-based beanstalkd queue broker.

Written in Go, cmdstalk uses the kr/beanstalk library to interact with the beanstalkd queue daemon.

Each job is passed as stdin to a new instance of the configured worker command. On exit(0) the job is deleted. On exit(1) (or any non-zero status) the job is released with an exponential-backoff delay (releases^4), up to 10 times.

If the worker has not finished by the time the job TTR is reached, the worker is killed (SIGTERM, SIGKILL) and the job is allowed to time out. When the job is subsequently reserved, the timeouts: 1 will cause it to be buried.

In this way, job workers can be arbitrary commands, and queue semantics are reduced down to basic unix concepts of exit status and signals.

Install

From source:

# Make sure you have a sane $GOPATH
go get github.com/99designs/cmdstalk

From binary:

https://github.com/99designs/cmdstalk/releases

Usage

cmdstalk -help
# Usage of ./cmdstalk:
#   -address="127.0.0.1:11300": beanstalkd TCP address.
#   -all=false: Listen to all tubes, instead of -tubes=...
#   -cmd="": Command to run in worker.
#   -per-tube=1: Number of workers per tube.
#   -tubes=[default]: Comma separated list of tubes.

# Watch three specific tubes.
cmdstalk -cmd="/path/to/your/worker --your=flags --here" -tubes="one,two,three"

# Watch all current and future tubes, four workers per tube.
cmdstalk -all -cmd="cat" -per-tube=4

Dev

gpm is used to track dependencies. Make sure you have a sane $GOPATH etc, then brew install gpm and gpm install.

# Run all tests, with minimal/buffered output.
go test ./...

# Run tests in the broker package with steaming output.
(cd broker && go test -v)

# Run cmdstalk from source.
go run cmdstalk.go -cmd='hexdump -C' -tubes="default,another"

# Build and run a binary.
go build
file cmdstalk # cmdstalk: Mach-O 64-bit executable x86_64

Release

# Set up cross-compiling tool.
go get github.com/mitchellh/gox
gox -build-toolchain -os="darwin linux" -arch="amd64"

# Compile for various systems.
gox -os="darwin linux" -arch="amd64"
gzip cmdstalk_*_*

# Create a release.
open https://github.com/99designs/cmdstalk/releases/new

TODO

  • Graceful shutdown.
  • SIGKILL recalcitrant worker processes.
  • Logging improvements; stdout/stderr, concurrency-safety.
  • Interactive mode; single-concurrency, prompt for action for each job.

Created by Paul Annesley and Lachlan Donald.

© Copyright 2014 99designs Inc.

cmdstalk's People

Contributors

pda avatar

Watchers

 avatar

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.