= beanworker
== DESCRIPTION:
It is a worker-side Beanstalk-based job-queueing dispatcher
This is a pre-release, I will complete tests and docs in couple days
== REQUIREMENTS:
== USAGE
$ beanworker <jobs.rb> <host:port|path/to/file.yml> [-d|--daemonize [-m|--monitor] [-P|--pid <path/to/pid/dir>] ]
-d|--daemonize - process will go in background
-m|--monitor - process will be started with monitor, that will restart it when it crushes
-P|--pid - path to the directory, where pid-file(s) will be saved, default is current directory
== DSL
jobs.rb:
class SomeWorker
extend Beanworker::Worker
class << self
def some_job(args={})
do_somethin_slow_with(args)
end
def another_job(args={})
do_something
end
end
end
class AnotherWorker
extend Beanworker::Worker
class << self
def scheduled_job(args={})
do_somethin_slow_with(args)
end
end
schedule :scheduled_job, 2*24*3600, at: '04:30', timeout: 3600, { param1: 'some_value' }
end
SomeWorker.logger = AnotherWorker.logger = Logger.new('/var/log/somelog.log')
SomeWorker.perform 2, :some_job.
:another_job
AnotherWorker.perform 1, :scheduled_jov
== API:
RDoc will be later
Beanworker::Worker.perform number_of_threads, *jobs_names_to_listen
Beanworker::Worker.schedule method_name, period_to_run_in_secs, options={}, *args_to_method
options are:
- at: if period is in days (p % 1.day == 0), job will be performed exact at this time
- timeout: job will be killed if it performs more than this time in secs
== INSTALL:
gem install beanworker
== LICENSE:
(The MIT License)
Copyright (c) 2011 Andrew Shaydurov
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.