From 13b6e17a910ca12433f77c7c4e62e3d1c1ef8a3e Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Sat, 12 Jan 2008 03:58:23 +0000 Subject: let's actually run the jobs we get...untested svn path=/branches/new-fu/; revision=350 --- client/scireclient.pl | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/client/scireclient.pl b/client/scireclient.pl index c054e17..a9cfe20 100755 --- a/client/scireclient.pl +++ b/client/scireclient.pl @@ -37,6 +37,24 @@ sub run_main { } } + my @new_jobs = glob("$conf{job_dir}/queue/*.job"); + for (@new_jobs) { + my $job = Scire::Job->new(); + $job->load_jobfile($_); + $job->set_stdout_file("$conf{job_dir}/queue/$job->{jobid}.out"); + $job->set_stderr_file("$conf{job_dir}/queue/$job->{jobid}.err"); + $job->set_script_file("$conf{job_dir}/queue/$job->{jobid}.script"); + my $exitcode = $job->run(); + if(!$exitcode) { + # Successful job completion + system("mv $conf{job_dir}/queue/$job->{jobid}.* $conf{job_dir}/done/"); + } else { + # Job failed + system("mv $conf{job_dir}/queue/$job->{jobid}.* $conf{job_dir}/failed/"); + } + } + + talk_to_server(); } sub talk_to_server { @@ -196,10 +214,14 @@ sub get_jobs { sub scan_jobs_dir { #Scan the dirs for job files. - my @existing_jobs = glob("$conf{job_dir}/queue/*"); - my @failed_jobs = glob("$conf{job_dir}/failed/*"); - my @done_jobs = glob("$conf{job_dir}/done/*"); + my @existing_jobs = glob("$conf{job_dir}/queue/*.job"); + my @failed_jobs = glob("$conf{job_dir}/failed/*.job"); + my @done_jobs = glob("$conf{job_dir}/done/*.job"); + # XXX: this function should just scan the various job dirs, create a Scire::Job object + # for each job found, and return a structure containing the info, so that another + # function can act on the completed jobs + #Report on those jobs needing reporting. foreach my $job_file (@failed_jobs) { $job_file =~ /(\d+)\.job/; @@ -215,6 +237,7 @@ sub scan_jobs_dir { $job_file =~ /(\d+)\.job/; my $jobid = $1; my ($status, $message) = $comm->send_command("SET_JOB_STATUS", $jobid, "Done"); + # XXX: Send job output } return @existing_jobs; -- cgit v1.2.3-65-gdbad