Giter VIP home page Giter VIP logo

trinidad_worker_extension's Introduction

Trinidad Worker Extension

Background Workers for Trinidad running as background (daemon) threads along side your Rack/Rails deployed application.

Built upon https://github.com/kares/jruby-rack-worker thus supports popular worker libraries such as Resque and Delayed::Job.

Install

Along with Trinidad in your application's Gemfile :

  group :server do
    platform :jruby do
      gem 'trinidad', :require => false
      gem 'trinidad_worker_extension', :require => false
    end
  end
$ bundle

Or install it yourself as a plain old gem :

$ gem install trinidad_worker_extension

Configure

Like all extensions set it up in the configuration file (e.g. trinidad.yml).

Delayed::Job

---
  # ...
  extensions:
    worker:
      delayed_job:
        # all settings here are optional
        thread_count: 1
        thread_priority: NORM
        # DJ specifics (optional as well) :
        QUEUE: mailers,tasks
        READ_AHEAD: 3 # default 5
        SLEEP_DELAY: 2.5 # default 5
        #MIN_PRIORITY: 1
        #MAX_PRIORITY: 5

The following start script will be executed in each Thread http://git.io/yLSgLA

Resque

Trinidad.configure do |config|
  config[:extensions] = {
    :worker =>
      :resque => {
        :thread_priority => 4, # bit bellow NORM (5)
        'QUEUES' => ['*'],
        'INTERVAL' => 2.5, # default is 5.0
        'VERBOSE' => true, # verbose logging
        #'VVERBOSE' => true, # very_verbose logging
      }
  }
end

The following start script will be executed in each Thread http://git.io/XglTpw

Custom Worker

---
  # ...
  extensions:
    worker:
      custom:
        #script: require 'my_worker'; MyWorker.start
        script.path: "lib/my_worker/start_worker.rb"
        # all settings here are optional
        #thread_count: 1
        #thread_priority: NORM

If you'd like to specify custom parameters you can do so within the configuration file or the deployment descriptor as context init parameters or as java system properties, use the following code to obtain them in your code :

require 'jruby/rack/worker/env'
env = JRuby::Rack::Worker::ENV

worker = MyWorker.new
worker.queues = (env['QUEUES']).split(',')
# ...

Copyright

Copyright (c) 2012 Karol Bucek. See LICENSE (http://en.wikipedia.org/wiki/MIT_License) for details.

trinidad_worker_extension's People

Contributors

kares avatar

Watchers

 avatar  avatar

Forkers

trinidad wndxlori

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.