ls (l) Show queues and jobs on them
mach List known machines and groups
prun (pr) Parallel version of `run'
+queue Operations on queues
run (r) Run queued jobs
AMEN
exit 0;
--- /dev/null
+#!/usr/bin/perl
+# Batch EXecutor 3.0 -- Operations on Queues
+# (c) 2011-2012 Martin Mares <mj@ucw.cz>
+
+use strict;
+use warnings;
+use Getopt::Long;
+use BEX;
+
+my $init;
+
+GetOptions(
+ "init!" => \$init,
+) && @ARGV == 1 or die <<AMEN ;
+Usage: bex queue [<options>] <queue>
+
+Options:
+--init Create a new queue
+AMEN
+
+my $queue_name = shift @ARGV;
+
+if ($init) {
+ my $path = $BEX::Config::home . '/' . $queue_name;
+ -d $path and die "Queue directory $path already exists\n";
+ mkdir $path;
+ mkdir "$path/hosts";
+ mkdir "$path/jobs";
+ print "Queue $queue_name initialized.\n";
+} else {
+ my $queue = BEX::Queue->new($queue_name);
+ print "Queue $queue is OK\n";
+}
my ($class, $name) = @_;
$name //= 'queue';
my $path = $BEX::Config::home . '/' . $name;
- -d $path or die "Queue directory $path does not exist\n";
- for my $d ("hosts", "jobs") {
- -d "$path/$d" or mkdir "$path/$d" or die "Cannot create directory $path/$d: $!";
- }
+ -d $path or die "Queue directory $path does not exist (use bex queue --init to create it)\n";
+ -d "$path/hosts" && -d "$path/jobs" or die "Queue directory $path is misconfigured\n";
my $queue = {
'Name' => $name,
'Path' => $path,
delete $queue->{'LockName'};
}
-# Unsafe (does not check fcntl, only existence of a lock file), but should be enough for bq
+# Unsafe (does not check fcntl, only existence of a lock file), but should be enough for `bex ls'
sub is_locked($$$) {
my ($queue, $machine, $jid) = @_;
given ($BEX::Config::locking_scheme) {