2 # Batch EXecutor 2.0 -- Insert to Queue
3 # (c) 2011 Martin Mares <mj@ucw.cz>
16 "q|queue=s" => \$queue_name,
18 Usage: benq [<options>] [!]<machine-or-class> ...
21 -q, --queue=<name> Insert new jobs to the given queue
25 @ARGV or die "No machines specified\n";
26 my @machines = BEX::Config::parse_machine_list(@ARGV);
27 @machines or die "No machines match\n";
29 # Create job template and let the user edit it
30 my $job = BEX::Job->new;
32 my $orig_stat = stat($fn) or die;
33 system "editor", $fn and die "Editor exited with an error, file kept as $fn\n";
34 my $new_stat = stat($fn) or die "File $fn disappeared under my hands: $!\n";
35 if ($new_stat->mtime <= $orig_stat->mtime && $new_stat->size == $orig_stat->size) {
40 # Re-load the job and put it to the queue
41 $job = BEX::Job->new_from_file($fn);
42 print "New job ", $job->id, "\n";
43 my $queue = BEX::Queue->new($queue_name);
44 for my $m (@machines) {
45 if ($queue->enqueue($m, $job)) {
46 $queue->write_job_status($m, $job->id, { 'Time' => time, 'Status' => 'NEW' });
49 print "\t$m (already queued)\n";
53 # Remove the temporary file