rq-ruby1.8 3.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +22 -0
- data/Gemfile.lock +22 -0
- data/INSTALL +166 -0
- data/LICENSE +10 -0
- data/Makefile +6 -0
- data/README +1183 -0
- data/Rakefile +37 -0
- data/TODO +24 -0
- data/TUTORIAL +230 -0
- data/VERSION +1 -0
- data/bin/rq +902 -0
- data/bin/rqmailer +865 -0
- data/example/a.rb +7 -0
- data/extconf.rb +198 -0
- data/gemspec.rb +40 -0
- data/install.rb +210 -0
- data/lib/rq.rb +155 -0
- data/lib/rq/arrayfields.rb +371 -0
- data/lib/rq/backer.rb +31 -0
- data/lib/rq/configfile.rb +82 -0
- data/lib/rq/configurator.rb +40 -0
- data/lib/rq/creator.rb +54 -0
- data/lib/rq/cron.rb +144 -0
- data/lib/rq/defaultconfig.txt +5 -0
- data/lib/rq/deleter.rb +51 -0
- data/lib/rq/executor.rb +40 -0
- data/lib/rq/feeder.rb +527 -0
- data/lib/rq/ioviewer.rb +48 -0
- data/lib/rq/job.rb +51 -0
- data/lib/rq/jobqueue.rb +947 -0
- data/lib/rq/jobrunner.rb +110 -0
- data/lib/rq/jobrunnerdaemon.rb +193 -0
- data/lib/rq/lister.rb +47 -0
- data/lib/rq/locker.rb +43 -0
- data/lib/rq/lockfile.rb +564 -0
- data/lib/rq/logging.rb +124 -0
- data/lib/rq/mainhelper.rb +189 -0
- data/lib/rq/orderedautohash.rb +39 -0
- data/lib/rq/orderedhash.rb +240 -0
- data/lib/rq/qdb.rb +733 -0
- data/lib/rq/querier.rb +98 -0
- data/lib/rq/rails.rb +80 -0
- data/lib/rq/recoverer.rb +28 -0
- data/lib/rq/refresher.rb +80 -0
- data/lib/rq/relayer.rb +283 -0
- data/lib/rq/resource.rb +22 -0
- data/lib/rq/resourcemanager.rb +40 -0
- data/lib/rq/resubmitter.rb +100 -0
- data/lib/rq/rotater.rb +98 -0
- data/lib/rq/sleepcycle.rb +46 -0
- data/lib/rq/snapshotter.rb +40 -0
- data/lib/rq/sqlite.rb +286 -0
- data/lib/rq/statuslister.rb +48 -0
- data/lib/rq/submitter.rb +113 -0
- data/lib/rq/toucher.rb +182 -0
- data/lib/rq/updater.rb +94 -0
- data/lib/rq/usage.rb +1222 -0
- data/lib/rq/util.rb +304 -0
- data/rdoc.sh +17 -0
- data/rq-ruby1.8.gemspec +120 -0
- data/test/.gitignore +1 -0
- data/test/test_rq.rb +145 -0
- data/white_box/crontab +2 -0
- data/white_box/joblist +8 -0
- data/white_box/killrq +18 -0
- data/white_box/rq_killer +27 -0
- metadata +208 -0
data/Gemfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Runtime dependencies
|
7
|
+
# gem "bio", ">= 1.3.1"
|
8
|
+
# gem "bio-logger", "> 0.8.0"
|
9
|
+
# gem "nokogiri", ">= 1.4.4"
|
10
|
+
gem "posixlock"
|
11
|
+
gem "arrayfields"
|
12
|
+
gem "lockfile"
|
13
|
+
# gem "sqlite-1.3.1" # on rubygems?
|
14
|
+
|
15
|
+
# Add dependencies to develop your gem here.
|
16
|
+
# Include everything needed to run rake, tests, features, etc.
|
17
|
+
group :development do
|
18
|
+
# gem "rspec", "~> 2.3.0"
|
19
|
+
gem "bundler", "~> 1.0.15"
|
20
|
+
gem "jeweler", "~> 1.6.4"
|
21
|
+
# gem "rcov", ">= 0"
|
22
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
arrayfields (4.7.4)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.6.4)
|
7
|
+
bundler (~> 1.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
lockfile (1.4.3)
|
11
|
+
posixlock (0.0.1)
|
12
|
+
rake (0.9.2)
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
arrayfields
|
19
|
+
bundler (~> 1.0.15)
|
20
|
+
jeweler (~> 1.6.4)
|
21
|
+
lockfile
|
22
|
+
posixlock
|
data/INSTALL
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
=== Rubygems
|
2
|
+
|
3
|
+
The current version of rq runs on ruby1.8. A gem is available on rubygems:
|
4
|
+
|
5
|
+
https://rubygems.org/gems/rq-ruby1.8
|
6
|
+
|
7
|
+
install with
|
8
|
+
|
9
|
+
gem1.8 install rq-ruby1.8
|
10
|
+
|
11
|
+
which should include:
|
12
|
+
|
13
|
+
- gem1.8 install posixlock
|
14
|
+
- gem1.8 install arrayfields
|
15
|
+
- gem1.8 install lockfile
|
16
|
+
|
17
|
+
sqlite-1.3.1, however, is not on rubygems, so you may need to:
|
18
|
+
|
19
|
+
- install sqlite2 (Debian apt-get install libsqlite0-dev)
|
20
|
+
- wget http://rubyforge.org/frs/download.php/1070/sqlite-1.3.1.gem
|
21
|
+
- gem1.8 install sqlite-1.3.1.gem
|
22
|
+
- gem1.8 install rq-ruby1.8 (or run from source)
|
23
|
+
|
24
|
+
Also available from http://bio4.dnsalias.net/download/gem/ruby1.8/
|
25
|
+
|
26
|
+
run with, for example
|
27
|
+
|
28
|
+
ln -s /var/lib/gems/1.8/gems/rq-ruby1.8-3.4.3/bin/rq /usr/local/bin/rq
|
29
|
+
rq --help
|
30
|
+
|
31
|
+
=== Debian
|
32
|
+
|
33
|
+
On Debian systems, the recommended procedure is to use Debian apt on all
|
34
|
+
machines. For now, use the 3.4.3 install, as documented in the README!
|
35
|
+
|
36
|
+
This has been tested on Debian Squeeze (BioLinux Minimal):
|
37
|
+
|
38
|
+
root@vagrant-debian-squeeze:/home/vagrant# gem1.8 install rq-ruby1.8
|
39
|
+
Building native extensions. This could take a while...
|
40
|
+
Successfully installed posixlock-0.0.1
|
41
|
+
Successfully installed arrayfields-4.7.4
|
42
|
+
Successfully installed lockfile-1.4.3
|
43
|
+
Successfully installed rq-ruby1.8-3.4.3
|
44
|
+
4 gems installed
|
45
|
+
Installing ri documentation for posixlock-0.0.1...
|
46
|
+
Installing ri documentation for arrayfields-4.7.4...
|
47
|
+
Installing ri documentation for lockfile-1.4.3...
|
48
|
+
Installing ri documentation for rq-ruby1.8-3.4.3...
|
49
|
+
Installing RDoc documentation for posixlock-0.0.1...
|
50
|
+
Installing RDoc documentation for arrayfields-4.7.4...
|
51
|
+
Installing RDoc documentation for lockfile-1.4.3...
|
52
|
+
Installing RDoc documentation for rq-ruby1.8-3.4.3...
|
53
|
+
|
54
|
+
ln -s /var/lib/gems/1.8/gems/rq-ruby1.8-3.4.3/bin/rq /usr/local/bin/rq
|
55
|
+
|
56
|
+
apt-get install libsqlite0-dev
|
57
|
+
Setting up libsqlite0 (2.8.17-6) ...
|
58
|
+
Setting up libsqlite0-dev (2.8.17-6) ...
|
59
|
+
wget http://rubyforge.org/frs/download.php/1070/sqlite-1.3.1.gem
|
60
|
+
Saving to: `sqlite-1.3.1.gem'
|
61
|
+
100%[======================================>] 41,278 --.-K/s in 0.1s
|
62
|
+
2011-07-21 11:36:21 (347 KB/s) - `sqlite-1.3.1.gem' saved [41278/41278]
|
63
|
+
|
64
|
+
root@vagrant-debian-squeeze:/home/vagrant# gem1.8 install sqlite-1.3.1.gem
|
65
|
+
Building native extensions. This could take a while...
|
66
|
+
Successfully installed sqlite-1.3.1
|
67
|
+
1 gem installed
|
68
|
+
Installing ri documentation for sqlite-1.3.1...
|
69
|
+
Installing RDoc documentation for sqlite-1.3.1...
|
70
|
+
root@vagrant-debian-squeeze:/home/vagrant# rq --help
|
71
|
+
NAME
|
72
|
+
|
73
|
+
rq v3.4.3
|
74
|
+
|
75
|
+
(the end!)
|
76
|
+
|
77
|
+
(below will become available later)
|
78
|
+
|
79
|
+
* apt-get install rq-ruby1.8
|
80
|
+
|
81
|
+
which resolves all dependencies, or alternatively
|
82
|
+
|
83
|
+
* Download the rq deb file from http://bio4.dnsalias.net/download/Debian/
|
84
|
+
* apt-get install libposixlock-ruby1.8 libsqlite3-ruby1.8 ruby1.8
|
85
|
+
* dpkg --force-architecture -i rq-ruby1.8-ver.deb
|
86
|
+
|
87
|
+
which works on on 32-bits and 64-bits systems. The commands
|
88
|
+
|
89
|
+
* rq ~/queue create
|
90
|
+
* rq ~/queue status
|
91
|
+
|
92
|
+
should show
|
93
|
+
|
94
|
+
jobs:
|
95
|
+
pending: 0
|
96
|
+
holding: 0
|
97
|
+
running: 0
|
98
|
+
finished: 0
|
99
|
+
dead: 0
|
100
|
+
total: 0
|
101
|
+
temporal: {}
|
102
|
+
performance:
|
103
|
+
avg_time_per_job: 00h00m00.00s
|
104
|
+
n_jobs_in_last_hrs:
|
105
|
+
1: 0
|
106
|
+
12: 0
|
107
|
+
24: 0
|
108
|
+
exit_status:
|
109
|
+
successes: 0
|
110
|
+
failures: 0
|
111
|
+
ok: 0
|
112
|
+
|
113
|
+
=== NFS central
|
114
|
+
|
115
|
+
The second option is to build and install once and distribute through
|
116
|
+
NFS. Use the tgz installation, which includes an ./all/ directory. On
|
117
|
+
modern systems your mileage may vary as the Ruby build breaks on gcc
|
118
|
+
version >4.4
|
119
|
+
|
120
|
+
* Unpack rq-ver.tgz file
|
121
|
+
|
122
|
+
* cd into ./all/
|
123
|
+
|
124
|
+
* ./install.sh /full/path/to/a/nfs/mounted/directory/
|
125
|
+
|
126
|
+
* the nfs mounted path above should be visible by all cluster nodes.
|
127
|
+
__all__ required software will be installed into this directory root. when
|
128
|
+
complete all that's needed is a
|
129
|
+
|
130
|
+
export PATH=/full/path/to/a/nfs/mounted/directory/bin:$PATH
|
131
|
+
|
132
|
+
(note 'bin') to use rq
|
133
|
+
|
134
|
+
* this is the second best procedure since it will result in a single nfs
|
135
|
+
install which all cluster nodes can use. The other install methods mean
|
136
|
+
you will have to install rq on __each__ node you plan to use it on.
|
137
|
+
|
138
|
+
=== RUBYGEMS
|
139
|
+
|
140
|
+
(currently defunct, awaits updating rq to Ruby 1.9.x and sqlite3)
|
141
|
+
|
142
|
+
* gem install rq
|
143
|
+
|
144
|
+
=== STANDARD
|
145
|
+
|
146
|
+
(in rq version <=3.4.0)
|
147
|
+
|
148
|
+
* install all packages in ./depends/packages manually
|
149
|
+
|
150
|
+
* ruby install.rb
|
151
|
+
|
152
|
+
=== From source (github)
|
153
|
+
|
154
|
+
The current version of rq runs on ruby1.8, using bundler and jeweler:
|
155
|
+
|
156
|
+
gem1.8 install bundler
|
157
|
+
Successfully installed bundler-1.0.15
|
158
|
+
|
159
|
+
gem1.8 install jeweler
|
160
|
+
Successfully installed jeweler-1.6.4
|
161
|
+
|
162
|
+
git clone https://pjotrp@github.com/pjotrp/rq.git
|
163
|
+
cd rq/
|
164
|
+
rake gemspec
|
165
|
+
rake build # creates gem in ./pkg
|
166
|
+
|
data/LICENSE
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
Copyright (c) 2011, Ara Howard (ara.t.howard@gmail.com)
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
5
|
+
|
6
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
7
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
8
|
+
* Neither the name of rq nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
9
|
+
|
10
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/Makefile
ADDED
data/README
ADDED
@@ -0,0 +1,1183 @@
|
|
1
|
+
NAME
|
2
|
+
|
3
|
+
rq v3.4.3
|
4
|
+
|
5
|
+
SYNOPSIS
|
6
|
+
|
7
|
+
rq (queue | export RQ_Q=q) mode [mode_args]* [options]*
|
8
|
+
|
9
|
+
|
10
|
+
URIS
|
11
|
+
|
12
|
+
https://github.com/pjotrp/rq - main website
|
13
|
+
http://www.linuxjournal.com/article/7922
|
14
|
+
|
15
|
+
and
|
16
|
+
|
17
|
+
http://rubyforge.org/projects/codeforpeople/
|
18
|
+
http://codeforpeople.com/lib/ruby/rq/
|
19
|
+
|
20
|
+
LICENSE
|
21
|
+
|
22
|
+
rq is distributed under the BSD license, see the ./LICENSE file
|
23
|
+
|
24
|
+
INSTALL
|
25
|
+
|
26
|
+
See the ./INSTALL file, but quickly
|
27
|
+
|
28
|
+
gems (per node):
|
29
|
+
|
30
|
+
gem >=3.4.3:
|
31
|
+
|
32
|
+
- install sqlite2 (Debian apt-get install libsqlite0-dev)
|
33
|
+
- wget http://rubyforge.org/frs/download.php/1070/sqlite-1.3.1.gem
|
34
|
+
- gem1.8 install sqlite-1.3.1.gem
|
35
|
+
- gem1.8 install posixlock
|
36
|
+
- gem1.8 install arrayfields
|
37
|
+
- gem1.8 install lockfile
|
38
|
+
- gem1.8 install rq-ruby1.8 (or run from source)
|
39
|
+
|
40
|
+
Also available from http://bio4.dnsalias.net/download/gem/ruby1.8/
|
41
|
+
|
42
|
+
manual (cluster wide):
|
43
|
+
|
44
|
+
(note, this procedure is out of date and breaks on gcc 4.4 and later)
|
45
|
+
- download latest release from http://codeforpeople.com/lib/ruby/rq/
|
46
|
+
- tar xvfz rq-X.X.X.tgz
|
47
|
+
- cd rq-X-X-X
|
48
|
+
- cd all
|
49
|
+
- ./install.sh /full/path/to/nfs/mounted/directory/
|
50
|
+
|
51
|
+
Debian flavours:
|
52
|
+
|
53
|
+
see ./INSTALL file for latest
|
54
|
+
|
55
|
+
DESCRIPTION
|
56
|
+
|
57
|
+
ruby queue (rq) is a zero-admin zero-configuration tool used to create instant
|
58
|
+
unix clusters. rq requires only a central nfs filesystem in order to manage a
|
59
|
+
simple sqlite database as a distributed priority work queue. this simple
|
60
|
+
design allows researchers with minimal unix experience to install and
|
61
|
+
configure, in only a few minutes and without root privileges, a robust unix
|
62
|
+
cluster capable of distributing processes to many nodes - bringing dozens of
|
63
|
+
powerful cpus to their knees with a single blow. clearly this software should
|
64
|
+
be kept out of the hands of free radicals, seti enthusiasts, and one mr. j
|
65
|
+
safran.
|
66
|
+
|
67
|
+
the central concept of rq is that n nodes work in isolation to pull jobs
|
68
|
+
from an centrally mounted nfs priority work queue in a synchronized fashion.
|
69
|
+
the nodes have absolutely no knowledge of each other and all communication
|
70
|
+
is done via the queue meaning that, so long as the queue is available via
|
71
|
+
nfs and a single node is running jobs from it, the system will continue to
|
72
|
+
process jobs. there is no centralized process whatsoever - all nodes work
|
73
|
+
to take jobs from the queue and run them as fast as possible. this creates
|
74
|
+
a system which load balances automatically and is robust in face of node
|
75
|
+
failures.
|
76
|
+
|
77
|
+
although the rq system is simple in it's design it features powerful
|
78
|
+
functionality such as priority management, predicate and sql query, compact
|
79
|
+
streaming command-line processing, programmable api, hot-backup, and
|
80
|
+
input/capture of the stdin/stdout/stderr io streams of remote jobs. to date
|
81
|
+
rq has had no reported runtime failures and is in operation at
|
82
|
+
dozens of research centers around the world. while rq is written in
|
83
|
+
the Ruby programming language, there is no Ruby programming
|
84
|
+
involved in using rq.
|
85
|
+
|
86
|
+
INVOCATION
|
87
|
+
|
88
|
+
the first argument to any rq command is the always the name of the queue
|
89
|
+
while the second is the mode of operation. the queue name may be omitted
|
90
|
+
if, and only if, the environment variable RQ_Q has been set to contain the
|
91
|
+
absolute path of target queue.
|
92
|
+
|
93
|
+
for instance, the command
|
94
|
+
|
95
|
+
~ > rq queue list
|
96
|
+
|
97
|
+
is equivalent to
|
98
|
+
|
99
|
+
~ > export RQ_Q=queue
|
100
|
+
~ > rq list
|
101
|
+
|
102
|
+
this facility can be used to create aliases for several queues, for example,
|
103
|
+
a .bashrc containing
|
104
|
+
|
105
|
+
alias MYQ="RQ_Q=/path/to/myq rq"
|
106
|
+
|
107
|
+
alias MYQ2="RQ_Q=/path/to/myq2 rq"
|
108
|
+
|
109
|
+
would allow syntax like
|
110
|
+
|
111
|
+
MYQ2 submit < joblist
|
112
|
+
|
113
|
+
MODES
|
114
|
+
|
115
|
+
rq operates in modes create, submit, resubmit, list, status, delete, update,
|
116
|
+
query, execute, configure, snapshot, lock, backup, rotate, feed, recover,
|
117
|
+
ioview, cron, help, and a few others. the meaning of 'mode_args' will
|
118
|
+
naturally change depending on the mode of operation.
|
119
|
+
|
120
|
+
the following mode abbreviations exist, note that not all modes have
|
121
|
+
abbreviations
|
122
|
+
|
123
|
+
c => create
|
124
|
+
s => submit
|
125
|
+
r => resubmit
|
126
|
+
l => list
|
127
|
+
ls => list
|
128
|
+
t => status
|
129
|
+
d => delete
|
130
|
+
rm => delete
|
131
|
+
u => update
|
132
|
+
q => query
|
133
|
+
e => execute
|
134
|
+
C => configure
|
135
|
+
S => snapshot
|
136
|
+
L => lock
|
137
|
+
b => backup
|
138
|
+
R => rotate
|
139
|
+
f => feed
|
140
|
+
io => ioview
|
141
|
+
0 => stdin
|
142
|
+
1 => stdout
|
143
|
+
2 => stderr
|
144
|
+
h => help
|
145
|
+
|
146
|
+
|
147
|
+
create, c :
|
148
|
+
|
149
|
+
creates a queue. the queue must be located on an nfs mounted file system
|
150
|
+
visible from all nodes intended to run jobs from it. nfs locking must be
|
151
|
+
functional on this file system.
|
152
|
+
|
153
|
+
examples :
|
154
|
+
|
155
|
+
0) to create a queue
|
156
|
+
~ > rq /path/to/nfs/mounted/q create
|
157
|
+
|
158
|
+
or, using the abbreviation
|
159
|
+
|
160
|
+
~ > rq /path/to/nfs/mounted/q c
|
161
|
+
|
162
|
+
|
163
|
+
submit, s :
|
164
|
+
|
165
|
+
submit jobs to a queue to be proccesed by some feeding node. any
|
166
|
+
'mode_args' are taken as the command to run. note that 'mode_args' are
|
167
|
+
subject to shell expansion - if you don't understand what this means do
|
168
|
+
not use this feature and pass jobs on stdin.
|
169
|
+
|
170
|
+
when running in submit mode a file may by specified as a list of commands
|
171
|
+
to run using the '--infile, -i' option. this file is taken to be a
|
172
|
+
newline separated list of commands to submit, blank lines and comments (#)
|
173
|
+
are allowed. if submitting a large number of jobs the input file method
|
174
|
+
is MUCH, more efficient. if no commands are specified on the command line
|
175
|
+
rq automatically reads them from stdin. yaml formatted files are also
|
176
|
+
allowed as input (http://www.yaml.org/) - note that the output of nearly
|
177
|
+
all rq commands is valid yaml and may, therefore, be piped as input into
|
178
|
+
the submit command. the leading '---' of yaml file may not be omitted.
|
179
|
+
|
180
|
+
when submitting the '--priority, -p' option can be used here to determine
|
181
|
+
the priority of jobs. priorities may be any whole number including
|
182
|
+
negative ones - zero is the default. note that submission of a high
|
183
|
+
priority job will NOT supplant a currently running low priority job, but
|
184
|
+
higher priority jobs WILL always migrate above lower priority jobs in the
|
185
|
+
queue in order that they be run as soon as possible. constant submission
|
186
|
+
of high priority jobs may create a starvation situation whereby low
|
187
|
+
priority jobs are never allowed to run. avoiding this situation is the
|
188
|
+
responsibility of the user. the only guaruntee rq makes regarding job
|
189
|
+
execution is that jobs are executed in an 'oldest-highest-priority' order
|
190
|
+
and that running jobs are never supplanted. jobs submitted with the
|
191
|
+
'--stage' option will not be eligible to be run by any node and will
|
192
|
+
remain in a 'holding' state until updated (see update mode) into the
|
193
|
+
'pending' mode, this option allows jobs to entered, or 'staged', in the
|
194
|
+
queue and then made candidates for running at a later date.
|
195
|
+
|
196
|
+
rq allows the stdin of commands to be provided and also captures the
|
197
|
+
stdout and stderr of any job run (of course standard shell redirects may
|
198
|
+
be used as well) and all three will be stored in a directory relative the
|
199
|
+
the queue itself. the stdin/stdout/stderr files are stored by job id and
|
200
|
+
there location (though relative to the queue) is shown in the output of
|
201
|
+
'list' (see docs for list).
|
202
|
+
|
203
|
+
|
204
|
+
examples :
|
205
|
+
|
206
|
+
0) submit the job ls to run on some feeding host
|
207
|
+
|
208
|
+
~ > rq q s ls
|
209
|
+
|
210
|
+
1) submit the job ls to run on some feeding host, at priority 9
|
211
|
+
|
212
|
+
~ > rq -p9 q s ls
|
213
|
+
|
214
|
+
2) submit a list of jobs from file. note the '-' used to specify
|
215
|
+
reading jobs from stdin
|
216
|
+
|
217
|
+
~ > cat joblist
|
218
|
+
job1.sh
|
219
|
+
job2.sh
|
220
|
+
job2.sh
|
221
|
+
|
222
|
+
~ > rq q submit --infile=joblist
|
223
|
+
|
224
|
+
3) submit a joblist on stdin
|
225
|
+
|
226
|
+
~ > cat joblist | rq q submit -
|
227
|
+
|
228
|
+
or
|
229
|
+
|
230
|
+
~ > rq q submit - <joblist
|
231
|
+
|
232
|
+
4) submit cat as a job, providing the stdin for cat from the file cat.in
|
233
|
+
|
234
|
+
~ > rq q submit cat --stdin=cat.in
|
235
|
+
|
236
|
+
5) submit cat as a job, providing the stdin for the cat job on stdin
|
237
|
+
|
238
|
+
~ > cat cat.in | rq q submit cat --stdin=-
|
239
|
+
|
240
|
+
or
|
241
|
+
|
242
|
+
~ > rq q submit cat --stdin=- <cat.in
|
243
|
+
|
244
|
+
6) submit 42 priority 9 jobs from a command file, marking them as
|
245
|
+
'important' using the '--tag, -t' option.
|
246
|
+
|
247
|
+
~ > wc -l cmdfile
|
248
|
+
42
|
249
|
+
|
250
|
+
~ > rq -p9 -timportant q s < cmdfile
|
251
|
+
|
252
|
+
6) re-submit all the 'important' jobs (see 'query' section below)
|
253
|
+
|
254
|
+
~ > rq q query tag=important | rq q s -
|
255
|
+
|
256
|
+
8) re-submit all jobs which are already finished (see 'list' section
|
257
|
+
below)
|
258
|
+
|
259
|
+
~ > rq q l f | rq q s
|
260
|
+
|
261
|
+
|
262
|
+
9) stage the job wont_run_yet to the queue in a 'holding' state. no
|
263
|
+
feeder will run this job until it's state is upgraded to 'pending'
|
264
|
+
|
265
|
+
~ > rq q s --stage wont_run_yet
|
266
|
+
|
267
|
+
|
268
|
+
resubmit, r :
|
269
|
+
|
270
|
+
resubmit jobs back to a queue to be proccesed by a feeding node. resubmit
|
271
|
+
is essentially equivalent to submitting a job that is already in the queue
|
272
|
+
as a new job and then deleting the original job except that using resubmit
|
273
|
+
is atomic and, therefore, safer and more efficient. resubmission respects
|
274
|
+
any previous stdin provided for job input. read docs for delete and
|
275
|
+
submit for more info.
|
276
|
+
|
277
|
+
examples :
|
278
|
+
|
279
|
+
0) resubmit job 42 to the queue
|
280
|
+
|
281
|
+
~> rq q resubmit 42
|
282
|
+
|
283
|
+
1) resubmit all failed jobs
|
284
|
+
|
285
|
+
~> rq q query exit_status!=0 | rq q resubmit -
|
286
|
+
|
287
|
+
2) resubmit job 4242 with different stdin
|
288
|
+
|
289
|
+
~ rq q resubmit 4242 --stdin=new_stdin.in
|
290
|
+
|
291
|
+
|
292
|
+
list, l, ls :
|
293
|
+
|
294
|
+
list mode lists jobs of a certain state or job id. state may be one of
|
295
|
+
pending, holding, running, finished, dead, or all. any 'mode_args' that
|
296
|
+
are numbers are taken to be job id's to list.
|
297
|
+
|
298
|
+
states may be abbreviated to uniqueness, therefore the following shortcuts
|
299
|
+
apply :
|
300
|
+
|
301
|
+
p => pending
|
302
|
+
h => holding
|
303
|
+
r => running
|
304
|
+
f => finished
|
305
|
+
d => dead
|
306
|
+
a => all
|
307
|
+
|
308
|
+
examples :
|
309
|
+
|
310
|
+
0) show everything in q
|
311
|
+
~ > rq q list all
|
312
|
+
|
313
|
+
or
|
314
|
+
|
315
|
+
~ > rq q l all
|
316
|
+
|
317
|
+
or
|
318
|
+
|
319
|
+
~ > export RQ_Q=q
|
320
|
+
~ > rq l
|
321
|
+
|
322
|
+
1) show q's pending jobs
|
323
|
+
~ > rq q list pending
|
324
|
+
|
325
|
+
2) show q's running jobs
|
326
|
+
~ > rq q list running
|
327
|
+
|
328
|
+
3) show q's finished jobs
|
329
|
+
~ > rq q list finished
|
330
|
+
|
331
|
+
4) show job id 42
|
332
|
+
~ > rq q l 42
|
333
|
+
|
334
|
+
5) show q's holding jobs
|
335
|
+
~ > rq q list holding
|
336
|
+
|
337
|
+
|
338
|
+
status, t :
|
339
|
+
|
340
|
+
status mode shows the global state the queue and statistics on it's the
|
341
|
+
cluster's performance. there are no 'mode_args'. the meaning of each
|
342
|
+
state is as follows:
|
343
|
+
|
344
|
+
pending => no feeder has yet taken this job
|
345
|
+
holding => a hold has been placed on this job, thus no feeder will start
|
346
|
+
it
|
347
|
+
running => a feeder has taken this job
|
348
|
+
finished => a feeder has finished this job
|
349
|
+
dead => rq died while running a job, has restarted, and moved
|
350
|
+
this job to the dead state
|
351
|
+
|
352
|
+
note that rq cannot move jobs into the dead state unless it has been
|
353
|
+
restarted. this is because no node has any knowledge of other nodes and
|
354
|
+
cannot possibly know if a job was started on a node that subsequently
|
355
|
+
died, or that it is simply taking a very long time to complete. only the
|
356
|
+
node that dies, upon restart, can determine that it owns jobs that 'were
|
357
|
+
started before it started running jobs', an impossibility, and move these
|
358
|
+
jobs into the dead state.
|
359
|
+
|
360
|
+
normally only a machine crash would cause a job to be placed into the dead
|
361
|
+
state. dead jobs are automatically restarted if, and only if, the job was
|
362
|
+
submitted with the '--restartable' flag.
|
363
|
+
|
364
|
+
status breaks down a variety of canned statistics about a nodes'
|
365
|
+
performance based solely on the jobs currently in the queue. only one
|
366
|
+
option affects the ouput: '--exit'. this option is used to specify
|
367
|
+
additionaly exit code mappings on which to report. normally rq will
|
368
|
+
report any job with an exit code of 0 as being 'successes' and any job
|
369
|
+
with an exit code that is not 0, or a status of 'dead', as being
|
370
|
+
'failures'. if the '--exit' switch is used then additional mappings can
|
371
|
+
be specified, note that the the semantics for 'successes' and 'failures'
|
372
|
+
does not change - this keyword specifies extra mappings.
|
373
|
+
|
374
|
+
examples :
|
375
|
+
|
376
|
+
0) show q's status
|
377
|
+
|
378
|
+
~ > rq q t
|
379
|
+
|
380
|
+
2) show q's status, consider any exit code of 42 will be listed as 'ok'
|
381
|
+
|
382
|
+
~ > rq q t --exit ok=42
|
383
|
+
|
384
|
+
3) show q's status, consider any exit code of 42 or 43 will be listed as
|
385
|
+
'ok' and 127 will be listed as 'command_not_found'. notice the quoting
|
386
|
+
required.
|
387
|
+
|
388
|
+
~ > rq q t --exit 'ok=42,43 command_not_found=127'
|
389
|
+
|
390
|
+
|
391
|
+
delete, d :
|
392
|
+
|
393
|
+
delete combinations of pending, holding, finished, dead, or jobs specified
|
394
|
+
by jid. the delete mode is capable of parsing the output of list and
|
395
|
+
query modes, making it possible to create custom filters to delete jobs
|
396
|
+
meeting very specific conditions.
|
397
|
+
|
398
|
+
'mode_args' are the same as for list.
|
399
|
+
|
400
|
+
note that it is NOT possible to delete a running job. rq has a
|
401
|
+
decentralized architechture which means that compute nodes are completely
|
402
|
+
independant of one another; an extension is that there is no way to
|
403
|
+
communicate the deletion of a running job from the queue the the node
|
404
|
+
actually running that job. it is not an error to force a job to die
|
405
|
+
prematurely using a facility such as an ssh command spawned on the remote
|
406
|
+
host to kill it. once a job has been noted to have finished, whatever the
|
407
|
+
exit status, it can be deleted from the queue.
|
408
|
+
|
409
|
+
examples :
|
410
|
+
|
411
|
+
0) delete all pending, finished, and dead jobs from a queue
|
412
|
+
|
413
|
+
~ > rq q d all
|
414
|
+
|
415
|
+
1) delete all pending jobs from a queue
|
416
|
+
|
417
|
+
~ > rq q d p
|
418
|
+
|
419
|
+
2) delete all finished jobs from a queue
|
420
|
+
|
421
|
+
~ > rq q d f
|
422
|
+
|
423
|
+
3) delete jobs via hand crafted filter program
|
424
|
+
|
425
|
+
~ > rq q list | yaml_filter_prog | rq q d -
|
426
|
+
|
427
|
+
an example ruby filter program (you have to love this)
|
428
|
+
|
429
|
+
~ > cat yaml_filter_prog
|
430
|
+
require 'yaml'
|
431
|
+
joblist = YAML::load STDIN
|
432
|
+
y joblist.select{|job| job['command'] =~ /bombing_program/}
|
433
|
+
|
434
|
+
this program reads the list of jobs (yaml) from stdin and then dumps
|
435
|
+
only those jobs whose command matches 'bombing_program', which is
|
436
|
+
subsequently piped to the delete command.
|
437
|
+
|
438
|
+
|
439
|
+
update, u :
|
440
|
+
|
441
|
+
update assumes all leading arguments are jids to update with subsequent
|
442
|
+
key=value pairs. currently only the 'command', 'priority', and 'tag'
|
443
|
+
fields of pending jobs can be generically updated and the 'state' field
|
444
|
+
may be toggled between pending and holding.
|
445
|
+
|
446
|
+
examples:
|
447
|
+
|
448
|
+
0) update the priority of job 42
|
449
|
+
|
450
|
+
~ > rq q update 42 priority=7
|
451
|
+
|
452
|
+
1) update the priority of all pending jobs
|
453
|
+
|
454
|
+
~ > rq q update pending priority=7
|
455
|
+
|
456
|
+
2) query jobs with a command matching 'foobar' and update their command
|
457
|
+
to be 'barfoo'
|
458
|
+
|
459
|
+
~ > rq q q "command like '%foobar%'" |\
|
460
|
+
rq q u command=barfoo
|
461
|
+
|
462
|
+
3) place a hold on jid 2
|
463
|
+
|
464
|
+
~ > rq q u 2 state=holding
|
465
|
+
|
466
|
+
4) place a hold on all jobs with tag=disk_filler
|
467
|
+
|
468
|
+
~ > rq q q tag=disk_filler | rq q u state=holding -
|
469
|
+
|
470
|
+
5) remove the hold on jid 2
|
471
|
+
|
472
|
+
~ > rq q u 2 state=pending
|
473
|
+
|
474
|
+
|
475
|
+
query, q :
|
476
|
+
|
477
|
+
query exposes the database more directly the user, evaluating the where
|
478
|
+
clause specified on the command line (or read from stdin). this feature
|
479
|
+
can be used to make a fine grained slection of jobs for reporting or as
|
480
|
+
input into the delete command. you must have a basic understanding of SQL
|
481
|
+
syntax to use this feature, but it is fairly intuitive in this limited
|
482
|
+
capacity.
|
483
|
+
|
484
|
+
examples:
|
485
|
+
|
486
|
+
0) show all jobs submitted within a specific 10 minute range
|
487
|
+
|
488
|
+
~ > a='2004-06-29 22:51:00'
|
489
|
+
|
490
|
+
~ > b='2004-06-29 22:51:10'
|
491
|
+
|
492
|
+
~ > rq q query "started >= '$a' and started < '$b'"
|
493
|
+
|
494
|
+
1) shell quoting can be tricky here so input on stdin is also allowed to
|
495
|
+
avoid shell expansion
|
496
|
+
|
497
|
+
~ > cat constraints.txt
|
498
|
+
started >= '2004-06-29 22:51:00' and
|
499
|
+
started < '2004-06-29 22:51:10'
|
500
|
+
|
501
|
+
~ > rq q query < contraints.txt
|
502
|
+
or (same thing)
|
503
|
+
|
504
|
+
~ > cat contraints.txt| rq q query -
|
505
|
+
|
506
|
+
2) this query output might then be used to delete those jobs
|
507
|
+
|
508
|
+
~ > cat contraints.txt | rq q q - | rq q d -
|
509
|
+
|
510
|
+
3) show all jobs which are either finished or dead
|
511
|
+
|
512
|
+
~ > rq q q "state='finished' or state='dead'"
|
513
|
+
|
514
|
+
4) show all jobs which have non-zero exit status
|
515
|
+
|
516
|
+
~ > rq q query exit_status!=0
|
517
|
+
|
518
|
+
5) if you plan to query groups of jobs with some common feature consider
|
519
|
+
using the '--tag, -t' feature of the submit mode which allows a user to
|
520
|
+
tag a job with a user defined string which can then be used to easily
|
521
|
+
query that job group
|
522
|
+
|
523
|
+
~ > rq q submit --tag=my_jobs - < joblist
|
524
|
+
|
525
|
+
~ > rq q query tag=my_jobs
|
526
|
+
|
527
|
+
|
528
|
+
6) in general all but numbers will need to be surrounded by single
|
529
|
+
quotes unless the query is a 'simple' one. a simple query is a query
|
530
|
+
with no boolean operators, not quotes, and where every part of it looks
|
531
|
+
like
|
532
|
+
|
533
|
+
key op value
|
534
|
+
|
535
|
+
with ** NO SPACES ** between key, op, and value. if, and only if,
|
536
|
+
the query is 'simple' rq will contruct the where clause
|
537
|
+
appropriately. the operators accepted, and their meanings, are
|
538
|
+
|
539
|
+
= : equivalence : sql =
|
540
|
+
=~ : matches : sql like
|
541
|
+
!~ : not matches : sql not like
|
542
|
+
|
543
|
+
match, in the context is ** NOT ** a regular expression but a sql
|
544
|
+
style string match. about all you need to know about sql matches is
|
545
|
+
that the '%' char matches anything. multiple simple queries will be
|
546
|
+
joined with boolean 'and'
|
547
|
+
|
548
|
+
this sounds confusing - it isn't. here are some examples of simple
|
549
|
+
queries
|
550
|
+
|
551
|
+
6.a)
|
552
|
+
query :
|
553
|
+
rq q query tag=important
|
554
|
+
|
555
|
+
where_clause :
|
556
|
+
"( tag = 'important' )"
|
557
|
+
|
558
|
+
6.b)
|
559
|
+
query :
|
560
|
+
rq q q priority=6 restartable=true
|
561
|
+
|
562
|
+
where_clause :
|
563
|
+
"( priority = 6 ) and ( restartable = 'true' )"
|
564
|
+
|
565
|
+
6.c)
|
566
|
+
query :
|
567
|
+
rq q q command=~%bombing_job% runner=~%node_1%
|
568
|
+
|
569
|
+
where_clause :
|
570
|
+
"( command like '%bombing_job%') and (runner like '%node_1%')"
|
571
|
+
|
572
|
+
|
573
|
+
execute, e :
|
574
|
+
|
575
|
+
execute mode is to be used by expert users with a knowledge of sql syntax
|
576
|
+
only. it follows the locking protocol used by rq and then allows the user
|
577
|
+
to execute arbitrary sql on the queue. unlike query mode a write lock on
|
578
|
+
the queue is obtained allowing a user to definitively shoot themselves in
|
579
|
+
the foot. for details on a queue's schema the file 'db.schema' in the
|
580
|
+
queue directory should be examined.
|
581
|
+
|
582
|
+
examples :
|
583
|
+
|
584
|
+
0) list all jobs
|
585
|
+
|
586
|
+
~ > rq q execute 'select * from jobs'
|
587
|
+
|
588
|
+
|
589
|
+
configure, C :
|
590
|
+
|
591
|
+
this mode is not supported yet.
|
592
|
+
|
593
|
+
|
594
|
+
snapshot, p :
|
595
|
+
|
596
|
+
snapshot provides a means of taking a snapshot of the q. use this feature
|
597
|
+
when many queries are going to be run; for example when attempting to
|
598
|
+
figure out a complex pipeline command your test queries will not compete
|
599
|
+
with the feeders for the queue's lock. you should use this option
|
600
|
+
whenever possible to avoid lock competition.
|
601
|
+
|
602
|
+
examples:
|
603
|
+
|
604
|
+
0) take a snapshot using default snapshot naming, which is made via the
|
605
|
+
basename of the q plus '.snapshot'
|
606
|
+
|
607
|
+
~ > rq /path/to/nfs/q snapshot
|
608
|
+
|
609
|
+
1) use this snapshot to chceck status
|
610
|
+
|
611
|
+
~ > rq ./q.snapshot status
|
612
|
+
|
613
|
+
2) use the snapshot to see what's running on which host
|
614
|
+
|
615
|
+
~ > rq ./q.snapshot list running | grep `hostname`
|
616
|
+
|
617
|
+
note that there is also a snapshot option - this option is not the same as
|
618
|
+
the snapshot command. the option can be applied to ANY command. if in
|
619
|
+
effect then that command will be run on a snapshot of the database and the
|
620
|
+
snapshot then immediately deleted. this is really only useful if one were
|
621
|
+
to need to run a command against a very heavily loaded queue and did not
|
622
|
+
wish to wait to obtain the lock. eg.
|
623
|
+
|
624
|
+
0) get the status of a heavily loaded queue
|
625
|
+
|
626
|
+
~ > rq q t --snapshot
|
627
|
+
|
628
|
+
1) same as above
|
629
|
+
|
630
|
+
~ > rq q t -s
|
631
|
+
|
632
|
+
** IMPORTANT **
|
633
|
+
|
634
|
+
a really great way to hang all processing in your queue is to do this
|
635
|
+
|
636
|
+
rq q list | less
|
637
|
+
|
638
|
+
and then leave for the night. you hold a read lock you won't release
|
639
|
+
until less dies. this is what snapshot is made for! use it like
|
640
|
+
|
641
|
+
rq q list -s | less
|
642
|
+
|
643
|
+
now you've taken a snapshot of the queue to list so your locks affect no
|
644
|
+
one.
|
645
|
+
|
646
|
+
|
647
|
+
lock, L :
|
648
|
+
|
649
|
+
lock the queue and then execute an arbitrary shell command. lock mode
|
650
|
+
uses the queue's locking protocol to safely obtain a lock of the specified
|
651
|
+
type and execute a command on the user's behalf. lock type must be one of
|
652
|
+
|
653
|
+
(r)ead | (sh)ared | (w)rite | (ex)clusive
|
654
|
+
|
655
|
+
examples :
|
656
|
+
|
657
|
+
0) get a read lock on the queue and make a backup
|
658
|
+
|
659
|
+
~ > rq q L read -- cp -r q q.bak
|
660
|
+
|
661
|
+
(the '--' is needed to tell rq to stop parsing command line
|
662
|
+
options which allows the '-r' to be passed to the 'cp' command)
|
663
|
+
|
664
|
+
** IMPORTANT **
|
665
|
+
|
666
|
+
this is another fantastic way to freeze your queue - use with care!
|
667
|
+
|
668
|
+
|
669
|
+
backup, b :
|
670
|
+
|
671
|
+
backup mode is exactly the same as getting a read lock on the queue and
|
672
|
+
making a copy of it. this mode is provided as a convenience.
|
673
|
+
|
674
|
+
0) make a backup of the queue using default naming ( qname + timestamp + .bak )
|
675
|
+
|
676
|
+
~ > rq q b
|
677
|
+
|
678
|
+
1) make a backup of the queue as 'q.bak'
|
679
|
+
|
680
|
+
~ > rq q b q.bak
|
681
|
+
|
682
|
+
|
683
|
+
rotate, r :
|
684
|
+
|
685
|
+
rotate mode is conceptually similar to log rolling. normally the list of
|
686
|
+
finished jobs will grow without bound in a queue unless they are manually
|
687
|
+
deleted. rotation is a method of trimming finished jobs from a queue
|
688
|
+
without deleting them. the method used is that the queue is copied to a
|
689
|
+
'rotation'; all jobs that are dead or finished are deleted from the
|
690
|
+
original queue and all pending and running jobs are deleted from the
|
691
|
+
rotation. in this way the rotation becomes a record of the queue's
|
692
|
+
finished and dead jobs at the time the rotation was made.
|
693
|
+
|
694
|
+
0) rotate a queue using default rotation name
|
695
|
+
|
696
|
+
~ > rq q rotate
|
697
|
+
|
698
|
+
1) rotate a queue naming the rotation
|
699
|
+
|
700
|
+
~ > rq q rotate q.rotation
|
701
|
+
|
702
|
+
2) a crontab entry like this could be used to rotate a queue daily
|
703
|
+
|
704
|
+
59 23 * * * rq q rotate `date +q.%Y%m%d`
|
705
|
+
|
706
|
+
|
707
|
+
feed, f :
|
708
|
+
|
709
|
+
take jobs from the queue and run them on behalf of the submitter as
|
710
|
+
quickly as possible. jobs are taken from the queue in an 'oldest highest
|
711
|
+
priority' first order.
|
712
|
+
|
713
|
+
feeders can be run from any number of nodes allowing you to harness the
|
714
|
+
CPU power of many nodes simoultaneously in order to more effectively
|
715
|
+
clobber your network, anoy your sysads, and set output raids on fire.
|
716
|
+
|
717
|
+
the most useful method of feeding from a queue is to do so in daemon mode
|
718
|
+
so that if the process loses it's controling terminal it will not exit
|
719
|
+
when you exit your terminal session. use the '--daemon, -d' option to
|
720
|
+
accomplish this. by default only one feeding process per host per queue
|
721
|
+
is allowed to run at any given moment. because of this it is acceptable
|
722
|
+
to start a feeder at some regular interval from a cron entry since, if a
|
723
|
+
feeder is alreay running, the process will simply exit and otherwise a new
|
724
|
+
feeder will be started. in this way you may keep feeder processing
|
725
|
+
running even acroess machine reboots without requiring sysad intervention
|
726
|
+
to add an entry to the machine's startup tasks.
|
727
|
+
|
728
|
+
|
729
|
+
examples :
|
730
|
+
|
731
|
+
0) feed from a queue verbosely for debugging purposes, using a minimum
|
732
|
+
and maximum polling time of 2 and 4 respectively. you would NEVER
|
733
|
+
specify polling times this brief except for debugging purposes!!!
|
734
|
+
|
735
|
+
~ > rq q feed -v4 --min_sleep=2 --max_sleep=4
|
736
|
+
|
737
|
+
1) same as above, but viewing the executed sql as it is sent to the
|
738
|
+
database
|
739
|
+
|
740
|
+
~ > RQ_SQL_DEBUG=1 rq q feed -v4 --min_sleep=2 --max_sleep=4
|
741
|
+
|
742
|
+
2) feed from a queue in daemon mode - logging to /home/ahoward/rq.log
|
743
|
+
|
744
|
+
~ > rq q feed --daemon -l/home/$USER/rq.log
|
745
|
+
|
746
|
+
log rolling in daemon mode is automatic so your logs should never
|
747
|
+
need to be deleted to prevent disk overflow.
|
748
|
+
|
749
|
+
|
750
|
+
start :
|
751
|
+
|
752
|
+
the start mode is equivalent to running the feed mode except the --daemon
|
753
|
+
is implied so the process instantly goes into the background. also, if no
|
754
|
+
log (--log) is specified in start mode a default one is used. the default
|
755
|
+
is /home/$USER/$BASENAME_OF_Q.log
|
756
|
+
|
757
|
+
examples :
|
758
|
+
|
759
|
+
0) start a daemon process feeding from q
|
760
|
+
|
761
|
+
~ > rq q start
|
762
|
+
|
763
|
+
1) use something like this sample crontab entry to keep a feeder running
|
764
|
+
forever - it attempts to (re)start every fifteen minutes but exits if
|
765
|
+
another process is already feeding. output is only created when the
|
766
|
+
daemon is started so your mailbox will not fill up with this crontab
|
767
|
+
entry:
|
768
|
+
|
769
|
+
#
|
770
|
+
# crontab.sample
|
771
|
+
#
|
772
|
+
|
773
|
+
*/15 * * * * /path/to/bin/rq /path/to/q start
|
774
|
+
|
775
|
+
and entry like this on every node in your cluster is all that's needed
|
776
|
+
to keep your cluster going - even after a reboot.
|
777
|
+
|
778
|
+
|
779
|
+
shutdown :
|
780
|
+
|
781
|
+
tell a running feeder to finish any pending jobs and then to exit. this
|
782
|
+
is equivalent to sending signal 'SIGTERM' to the process - this is what
|
783
|
+
using 'kill pid' does by default.
|
784
|
+
|
785
|
+
examples :
|
786
|
+
|
787
|
+
0) stop a feeding process, if any, that is feeding from q. allow all
|
788
|
+
jobs to be finished first.
|
789
|
+
|
790
|
+
~ > rq q shutdown
|
791
|
+
|
792
|
+
** VERY IMPORTANT **
|
793
|
+
|
794
|
+
if you are keeping your feeder alive with a crontab entry you'll need to
|
795
|
+
comment it out before doing this or else it will simply re-start!!!
|
796
|
+
|
797
|
+
stop :
|
798
|
+
|
799
|
+
tell any running feeder to stop NOW. this sends signal 'SIGKILL' (-9) to
|
800
|
+
the feeder process. the same warning as for shutdown applies!!!
|
801
|
+
|
802
|
+
examples :
|
803
|
+
|
804
|
+
0) stop a feeding process, if any, that is feeding from q. allow NO
|
805
|
+
jobs to be finished first - exit instantly.
|
806
|
+
|
807
|
+
~ > rq q stop
|
808
|
+
|
809
|
+
cron :
|
810
|
+
|
811
|
+
when given 'start' for 'mode_args' this option automatically adds a
|
812
|
+
crontab entry to keep a feeder alive indefinitely and starts a feeder in
|
813
|
+
the background. this is a shortcut to start a feeder and ensure it stays
|
814
|
+
running forever, even across re-boots.
|
815
|
+
|
816
|
+
'stop' as an argument applys the inverse option: any crontab entry is
|
817
|
+
removed and the daemon shutdown nicely. a second argument of 'hard' will
|
818
|
+
do a stop instead of a shutdown.
|
819
|
+
|
820
|
+
the addition and subtraction of crontab entries is robust, however, if you
|
821
|
+
already have crontab lines maintaining your feeders with a vastly
|
822
|
+
different syntax it would be best to shut down, remove them, and then let
|
823
|
+
rq manage them. then again, some people are quite brave...
|
824
|
+
|
825
|
+
examples :
|
826
|
+
|
827
|
+
0) automatically add crontab entry and start daemon feeder
|
828
|
+
|
829
|
+
~ > rq q cron start
|
830
|
+
|
831
|
+
1) automatically remove crontab entry and shutdown daemon feeder nicely
|
832
|
+
|
833
|
+
~ > rq q cron shutdown
|
834
|
+
|
835
|
+
2) the same, but using stop instead of shutdown
|
836
|
+
|
837
|
+
~ > rq q cron stop
|
838
|
+
|
839
|
+
pid :
|
840
|
+
|
841
|
+
show the pid, if any, of the feeder on this host
|
842
|
+
|
843
|
+
~ > rq q feeder
|
844
|
+
---
|
845
|
+
pid : 3176
|
846
|
+
|
847
|
+
|
848
|
+
ioview, io :
|
849
|
+
|
850
|
+
as shown in the description for submit, a job maybe be provided stdin
|
851
|
+
during job submission. the stdout and stderr of the job are also captured
|
852
|
+
as the job is run. all three streams are captured in files located
|
853
|
+
relative to the queue. so, if one has submitted a job, and it's jid was
|
854
|
+
shown to be 42, by using something like
|
855
|
+
|
856
|
+
~ > rq /path/to/q submit myjob --stdin=myjob.in
|
857
|
+
---
|
858
|
+
-
|
859
|
+
jid : 42
|
860
|
+
priority : 0
|
861
|
+
...
|
862
|
+
stdin : stdin/42
|
863
|
+
stdout : stdout/42
|
864
|
+
stderr : stderr/42
|
865
|
+
...
|
866
|
+
command : myjob
|
867
|
+
|
868
|
+
the stdin file will exists as soon as the job is submitted and the others
|
869
|
+
will exist once the job has begun running. note that these paths are
|
870
|
+
shown relative to the queue. in this case the actual paths would be
|
871
|
+
|
872
|
+
/path/to/q/stdin/42
|
873
|
+
/path/to/q/stdout/42
|
874
|
+
/path/to/q/stderr/42
|
875
|
+
|
876
|
+
but, since our queue is nfs mounted the /path/to/q may or may not be the
|
877
|
+
same on every host. thus the path is a relative one. this can make it
|
878
|
+
anoying to view these files, but rq assists here with the ioview command.
|
879
|
+
the ioview command spawns an external editor to view all three files.
|
880
|
+
it's use is quite simple
|
881
|
+
|
882
|
+
examples :
|
883
|
+
|
884
|
+
0) view the stdin/stdout/stderr of job id 42
|
885
|
+
|
886
|
+
~ > rq q ioview 42
|
887
|
+
|
888
|
+
by default this will open up all three files in vim. the editor command
|
889
|
+
can be specified using the '--editor' option or the ENV var RQ_EDITOR.
|
890
|
+
the default value is 'vim -R -o' which allows all three files to be opened
|
891
|
+
in a single window.
|
892
|
+
|
893
|
+
|
894
|
+
stdin, 0 :
|
895
|
+
|
896
|
+
dump the stdinput (if any) provided to the job
|
897
|
+
|
898
|
+
examples :
|
899
|
+
|
900
|
+
0) dump the stdin for jid 42
|
901
|
+
|
902
|
+
~ > rq q stdin 42
|
903
|
+
|
904
|
+
|
905
|
+
stdout, 1 :
|
906
|
+
|
907
|
+
dump the stdoutput (if any) created by the job
|
908
|
+
|
909
|
+
examples :
|
910
|
+
|
911
|
+
0) dump the stdout for jid 42
|
912
|
+
|
913
|
+
~ > rq q stdout 42
|
914
|
+
|
915
|
+
|
916
|
+
stderr, 2 :
|
917
|
+
|
918
|
+
dump the stderrput (if any) created by the job
|
919
|
+
|
920
|
+
examples :
|
921
|
+
|
922
|
+
0) dump the stderr for jid 42
|
923
|
+
|
924
|
+
~ > rq q stderr 42
|
925
|
+
|
926
|
+
|
927
|
+
stdin4 :
|
928
|
+
|
929
|
+
show the path used for the stdin of a jid
|
930
|
+
|
931
|
+
examples :
|
932
|
+
|
933
|
+
0) show which file has job 42's stdin
|
934
|
+
|
935
|
+
~ > rq q stdin4 42
|
936
|
+
|
937
|
+
|
938
|
+
stdout4 :
|
939
|
+
|
940
|
+
show the path used for the stdout of a jid
|
941
|
+
|
942
|
+
examples :
|
943
|
+
|
944
|
+
0) show which file has job 42's stdout
|
945
|
+
|
946
|
+
~ > rq q stdout4 42
|
947
|
+
|
948
|
+
|
949
|
+
stderr4 :
|
950
|
+
|
951
|
+
show the path used for the stderr of a jid
|
952
|
+
|
953
|
+
examples :
|
954
|
+
|
955
|
+
0) show which file has job 42's stderr
|
956
|
+
|
957
|
+
~ > rq q stderr4 42
|
958
|
+
|
959
|
+
|
960
|
+
recover :
|
961
|
+
|
962
|
+
it is possible that a hardware failure might corrupt an rq database. this
|
963
|
+
isn't the kind of thing people like hearing, but it's true - hardware has
|
964
|
+
errors. in these situations a database can sometimes be readable, but not
|
965
|
+
writable, or some other combination. this has been reported only a
|
966
|
+
handful of times, nevertheless, this command wraps sqlite recovery to get
|
967
|
+
you rolling again, it's acceptable to perform recovery on a live rq
|
968
|
+
database with active feeders
|
969
|
+
|
970
|
+
examples :
|
971
|
+
|
972
|
+
0) recover!
|
973
|
+
|
974
|
+
~ > rq q recover
|
975
|
+
|
976
|
+
|
977
|
+
help, h :
|
978
|
+
|
979
|
+
this message
|
980
|
+
|
981
|
+
examples :
|
982
|
+
|
983
|
+
0) get this message
|
984
|
+
|
985
|
+
~> rq q help
|
986
|
+
|
987
|
+
or
|
988
|
+
|
989
|
+
~> rq help
|
990
|
+
|
991
|
+
NOTES
|
992
|
+
|
993
|
+
- realize that your job is going to be running on a remote host and this has
|
994
|
+
implications. paths, for example, should be absolute, not relative.
|
995
|
+
specifically the submitted job script must be visible from all hosts
|
996
|
+
currently feeding from a queue as must be the input and output
|
997
|
+
files/directories.
|
998
|
+
|
999
|
+
- jobs are currently run under the bash shell using the --login option.
|
1000
|
+
therefore any settings in your .bashrc will apply - specifically your PATH
|
1001
|
+
setting. you should not, however, rely on jobs running with any given
|
1002
|
+
environment.
|
1003
|
+
|
1004
|
+
- you need to consider __CAREFULLY__ what the ramifications of having
|
1005
|
+
multiple instances of your program all potentially running at the same
|
1006
|
+
time will be. for instance, it is beyond the scope of rq to ensure
|
1007
|
+
multiple instances of a given program will not overwrite each others
|
1008
|
+
output files. coordination of programs is left entirely to the user.
|
1009
|
+
|
1010
|
+
- the list of finished jobs will grow without bound unless you sometimes
|
1011
|
+
delete some (all) of them. the reason for this is that rq cannot know
|
1012
|
+
when the user has collected the exit_status of a given job, and so keeps
|
1013
|
+
this information in the queue forever until instructed to delete it. if
|
1014
|
+
you have collected the exit_status of you job(s) it is not an error to
|
1015
|
+
then delete that job from the finished list - the information is kept for
|
1016
|
+
your informational purposes only. in a production system it would be
|
1017
|
+
normal to periodically save, and then delete, all finished jobs.
|
1018
|
+
|
1019
|
+
- know that it is a VERY bad idea to spawn several dozen process all
|
1020
|
+
reading/writing huge output files to a single NFS server. use this
|
1021
|
+
paradigm instead
|
1022
|
+
|
1023
|
+
* copy/move data from global input space to local disk
|
1024
|
+
* process data
|
1025
|
+
* move data on local disk to global output space
|
1026
|
+
|
1027
|
+
this, of course, applies to any nfs processing, not just those jobs
|
1028
|
+
submitted to rq
|
1029
|
+
|
1030
|
+
the vsftp daemon is an excellent utility to have running on hosts in your
|
1031
|
+
cluster so anonymous ftp can be used to get/put data between any two
|
1032
|
+
hosts.
|
1033
|
+
|
1034
|
+
- know that nfs locking is very, very easy to break with firewalls put in
|
1035
|
+
place by overzealous system administrators. be postive not only that nfs
|
1036
|
+
locking works, but that lock recovery server/client crash or reboot works
|
1037
|
+
as well. http://nfs.sourceforge.net/ is the place to learn about NFS. my
|
1038
|
+
experience thus far is that there are ZERO properly configured NFS
|
1039
|
+
installations in the world. please test yours. contact me for a simple
|
1040
|
+
script which can assist you. beer donations required as payment.
|
1041
|
+
|
1042
|
+
ENVIRONMENT
|
1043
|
+
|
1044
|
+
RQ_Q: set to the full path of nfs mounted queue
|
1045
|
+
|
1046
|
+
the queue argument to all commands may be omitted if, and only if, the
|
1047
|
+
environment variable 'RQ_Q' contains the full path to the q. eg.
|
1048
|
+
|
1049
|
+
~ > export RQ_Q=/full/path/to/my/q
|
1050
|
+
|
1051
|
+
this feature can save a considerable amount of typing for those weak of
|
1052
|
+
wrist.
|
1053
|
+
|
1054
|
+
a shell script like this can also be used to avoid needing to type the
|
1055
|
+
queue name each and every time
|
1056
|
+
|
1057
|
+
~ > cat my_q
|
1058
|
+
#!/bin/sh
|
1059
|
+
rq /full/path/to/my/q "$@"
|
1060
|
+
|
1061
|
+
and then all operations become, for example
|
1062
|
+
|
1063
|
+
~> my_q submit my_mob
|
1064
|
+
~> my_q status
|
1065
|
+
~> my_q delete 42
|
1066
|
+
|
1067
|
+
RQ_OPTS | RQ_OPTIONS: specify extra options
|
1068
|
+
|
1069
|
+
this ENV var can be used to specify options which should always apply, for
|
1070
|
+
example
|
1071
|
+
|
1072
|
+
~ > export RQ_OPTS=--restartable
|
1073
|
+
|
1074
|
+
and shell script like this might be used to mark jobs submitted by a
|
1075
|
+
certain user and to always submit them at a negative priority
|
1076
|
+
|
1077
|
+
~ > cat username_q
|
1078
|
+
#!/bin/sh
|
1079
|
+
export RQ_OPTS="--tag=username --priority=-42"
|
1080
|
+
rq /full/path/to/my/q "$@"
|
1081
|
+
|
1082
|
+
actual command line options wil always override options given this way
|
1083
|
+
|
1084
|
+
DIAGNOSTICS
|
1085
|
+
|
1086
|
+
success : $? == 0
|
1087
|
+
failure : $? != 0
|
1088
|
+
|
1089
|
+
CREDITS
|
1090
|
+
|
1091
|
+
- kim baugh : patient tester and design input
|
1092
|
+
- jeff safran : the guy can break anything
|
1093
|
+
- chris elvidge : boss who made it possible
|
1094
|
+
- trond myklebust : tons of help with nfs
|
1095
|
+
- jamis buck : for writing the sqlite bindings for ruby
|
1096
|
+
- _why : for writing yaml for ruby
|
1097
|
+
- matz : for writing ruby
|
1098
|
+
|
1099
|
+
INSTALL
|
1100
|
+
|
1101
|
+
gem install rq-ruby1.8 (see top of page)
|
1102
|
+
|
1103
|
+
TEST
|
1104
|
+
|
1105
|
+
Install rq and
|
1106
|
+
|
1107
|
+
test_rq.rb
|
1108
|
+
|
1109
|
+
AUTHOR
|
1110
|
+
|
1111
|
+
Ara Howard <ara.t.howard@gmail.com> and Pjotr Prins <pjotr.public01@thebird.nl>
|
1112
|
+
|
1113
|
+
BUGS
|
1114
|
+
|
1115
|
+
0 < bugno && bugno <= 42
|
1116
|
+
|
1117
|
+
reports on github, or to Pjotr Prins <pjotr.public01@thebird.nl> and Ara Howard <ara.t.howard@gmail.com>
|
1118
|
+
|
1119
|
+
SEE ALSO
|
1120
|
+
|
1121
|
+
https://github.com/pjotrp/rq - main website
|
1122
|
+
|
1123
|
+
|
1124
|
+
OPTIONS
|
1125
|
+
--priority=priority, -p
|
1126
|
+
modes <submit, resubmit> : set the job(s) priority - lowest(0) ..
|
1127
|
+
highest(n) - (default 0)
|
1128
|
+
--tag=tag, -t
|
1129
|
+
modes <submit, resubmit> : set the job(s) user data tag
|
1130
|
+
--runner=runner
|
1131
|
+
modes <submit, resubmit> : set the job(s) required runner(s)
|
1132
|
+
--restartable
|
1133
|
+
modes <submit, resubmit> : set the job(s) to be restartable on node
|
1134
|
+
reboot
|
1135
|
+
--stage
|
1136
|
+
modes <submit, resubmit> : set the job(s) initial state to be holding
|
1137
|
+
(default pending)
|
1138
|
+
--infile=infile, -i
|
1139
|
+
modes <submit, resubmit> : infile
|
1140
|
+
--stdin=[stdin], -s
|
1141
|
+
modes <submit, resubmit, update> : stdin
|
1142
|
+
--data=data, -d
|
1143
|
+
modes <submit, resubmit, update> : data
|
1144
|
+
--quiet, -q
|
1145
|
+
modes <submit, resubmit, feed> : do not echo submitted jobs, fail
|
1146
|
+
silently if another process is already feeding
|
1147
|
+
--daemon, -D
|
1148
|
+
modes <feed> : spawn a daemon
|
1149
|
+
--max_feed=max_feed
|
1150
|
+
modes <feed> : the maximum number of concurrent jobs run
|
1151
|
+
--retries=retries
|
1152
|
+
modes <feed> : specify transaction retries
|
1153
|
+
--min_sleep=min_sleep
|
1154
|
+
modes <feed> : specify min sleep
|
1155
|
+
--max_sleep=max_sleep
|
1156
|
+
modes <feed> : specify max sleep
|
1157
|
+
--loops=loops, -L
|
1158
|
+
modes <feed> : specify how many times to loop (default forever)
|
1159
|
+
--exit=exit_code_map
|
1160
|
+
modes <status> : specify and exit code map
|
1161
|
+
--fields=fields, -f
|
1162
|
+
limit which fields of output to display
|
1163
|
+
--snapshot, -s
|
1164
|
+
operate on snapshot of queue
|
1165
|
+
--editor=editor, -e
|
1166
|
+
editor command capable of opening multiple files at once = (default
|
1167
|
+
ENV["RQ_EDITOR"] || "vim -R -o")
|
1168
|
+
--verbosity=[verbostiy], -v
|
1169
|
+
0|fatal < 1|error < 2|warn < 3|info < 4|debug - (default info)
|
1170
|
+
--log=path, -l
|
1171
|
+
set log file - (default stderr)
|
1172
|
+
--log_age=log_age
|
1173
|
+
daily | weekly | monthly - what age will cause log rolling (default
|
1174
|
+
nil)
|
1175
|
+
--log_size=log_size
|
1176
|
+
size in bytes - what size will cause log rolling (default nil)
|
1177
|
+
--dot_rq_dir=[dot_rq_dir]
|
1178
|
+
base dir for log/pidfile storage (default ~/.rq/full/path/to/queue)
|
1179
|
+
--help, -h
|
1180
|
+
this message
|
1181
|
+
--version
|
1182
|
+
show version number
|
1183
|
+
|