linkorb/commando

Commando: Execute Commands from Queues

v1.6.0 2016-12-16 19:00 UTC

README

Commando is a generic job-runner.

You can define your own commands in Json or Yaml files, and process jobs from different stores such as a directory of files, or a database.

It's goal is to make it easy to implement background jobs into your application.

An example workflow:

  1. You define a command "hello" in commando.yml:
commands:
  -
    name: hello
    template: echo "Hello {{ greeted }}"
    arguments:
      -
        name: greeted
        default: world
  1. Your app writes a job into /your/commando-path/new called 1.json:
{
  "command": "hello",
  "arguments": {
    "greeted": "universe"
  }
}
  1. You (or cron) runs commando run.
  2. Commando will check for new job files in the configured store (in this case a directory), execute the command, replacing arguments in the template with the passed job arguments, finally executing echo "Hello universe"
  3. Commando reports the job status back to the store, including exit codes, start/end times, total duration, and stdout and stderr
  4. Your app reports back to the user if needed, based on the status report.

Stores:

  • JsonDirJobStore: Manages jobs through json files with a simple directory structure
  • PdoJobStore: Manages jobs through a database table

Use-cases

You can replace the template with much more complex command-lines or shell-scripts.

Your app should treat these jobs as "fire-and-forget", meaning the app should not block, waiting for response. It's most ideal in scenarios where your triggers commands and doesn't need to know about the response right away:

Examples:

  • Update PDFs or reports in the background
  • Send emails and notifications
  • Create a database backup
  • Process uploaded image files
  • ...etc

License

Please refer to the included LICENSE.md file

Brought to you by the LinkORB Engineering team

687474703a2f2f7777772e6c696e6b6f72622e636f6d2f642f6d6574612f74696572312f696d616765732f6c696e6b6f7262656e67696e656572696e672d6c6f676f2e706e67
Check out our other projects at engineering.linkorb.com.

Btw, we're hiring!