# HG changeset patch # User normaldotcom # Date 2010-03-14 14:24:02 # Node ID 6331e72e3889884a13b0897e44e8efd0de73bdbb # Parent df7e1f917a6df62ddff4a0d862994b470d706e89 Added more debug info, checks... oddness still going on with unpackjob() diff --git a/src/server/simpleslave.c b/src/server/simpleslave.c --- a/src/server/simpleslave.c +++ b/src/server/simpleslave.c @@ -109,6 +109,7 @@ int main(int argc, char *argv[]) char *urltoTar; /* Full URL to the server-side location of job#.tgz */ char *pathtoTar; /* Full path to the location of the job#.tgz */ + char *pathtoTardir; char *urltoOutput; /* Full URL where output is posted */ char *pathtoOutput; /* Full path to the output (rendered) file */ @@ -140,8 +141,9 @@ int main(int argc, char *argv[]) fprintf(stderr, "Preparing to render frame %d in job %d\n", framenum, jobnum); - prepareJobPaths(jobnum, framenum, outputExt, datadir, &urltoTar, &pathtoTar, &pathtoJob, &pathtoJobfile, &urltoOutput, &pathtoOutput, &pathtoOutdir); - // free(outputExt); + prepareJobPaths(jobnum, framenum, outputExt, datadir, &urltoTar, &pathtoTar, &pathtoTardir, &pathtoJob, &pathtoJobfile, &urltoOutput, &pathtoOutput, &pathtoOutdir); + //free(outputExt); + mkdir(pathtoTardir, 0700); int dlret = downloadTar(urltoTar, pathtoTar); if(dlret == 0) fprintf(stderr,"Got data tarball\n"); @@ -150,7 +152,16 @@ int main(int argc, char *argv[]) else fprintf(stderr,"Using existing tarball %s...\n", pathtoTar); - unpackJob(pathtoJob, pathtoTar); + struct stat jbuffer; + int jstatus = stat(pathtoJobfile, &jbuffer); + if(jstatus == -1){ + fprintf(stderr,"Main job file does not exist, extracting...\n"); + + // If error unpacking tarball + if(unpackJob(pathtoJob, pathtoTar)) + return 1; + } + /* ignore return because directory may exist already */ fprintf(stderr,"Creating output directory %s\n", pathtoOutdir); @@ -173,6 +184,7 @@ int main(int argc, char *argv[]) int fstatus = stat(pathtoOutput, &buffer); if(fstatus == -1){ fprintf(stderr,"Frame was not rendered correctly! Scene may not have camera, or your blender installation is not working.\n"); + // @TODO: Unassign the frame on the server so other slaves can render it return 1; } else{ diff --git a/src/server/slave.c b/src/server/slave.c --- a/src/server/slave.c +++ b/src/server/slave.c @@ -115,6 +115,7 @@ int main(int argc, char *argv[]) int slavekey = atoi(username); // @TODO: Make this more friendly char *urltoTar; /* Full URL to the server-side location of job#.tgz */ char *pathtoTar; /* Full path to the location of the job#.tgz */ + char *pathtoTardir; char *urltoOutput; /* Full URL where output is posted */ char *pathtoOutput; /* Full path to the output (rendered) file */ @@ -146,7 +147,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Preparing to render frame %d in job %d\n", framenum, jobnum); - prepareJobPaths(jobnum, framenum, outputExt, datadir, &urltoTar, &pathtoTar, &pathtoJob, &pathtoJobfile, &urltoOutput, &pathtoOutput, &pathtoOutdir); + prepareJobPaths(jobnum, framenum, outputExt, datadir, &urltoTar, &pathtoTar,&pathtoTardir,&pathtoJob, &pathtoJobfile, &urltoOutput, &pathtoOutput, &pathtoOutdir); free(outputExt); if(downloadTar(urltoTar, pathtoTar)) diff --git a/src/server/slavefuncs.c b/src/server/slavefuncs.c --- a/src/server/slavefuncs.c +++ b/src/server/slavefuncs.c @@ -295,7 +295,7 @@ int exec_blender(char *input, char *outp char *command = "blender"; // @TODO: We currently expect this to be in PATH char *cmd[] = { command, "-b", "-o", output, input, "-f", frame_str, (char *)NULL }; // arguments for blender - fprintf(stderr,"Preparing to execute command: %s \"-b\" \"-o\" %s %s \"-f\" %s\n", command, output, input, frame_str); + fprintf(stderr,"Preparing to execute command: %s -b -o %s %s -f %s\n", command, output, input, frame_str); char buf[10]; struct execio *testrem; @@ -303,10 +303,10 @@ int exec_blender(char *input, char *outp fprintf(stderr,"Executing: %s\n", frame_str); ret = execio_open(&testrem, command, cmd); - buf[9] = '\0'; - while(!execio_read(testrem, buf, 9, &readlen)) + buf[20] = '\0'; + while(!execio_read(testrem, buf, 20, &readlen)) { - if(readlen > 9) { + if(readlen > 20) { fprintf(stderr, "Something is terribly wrong!\n"); } buf[readlen] = '\0'; @@ -377,11 +377,6 @@ int downloadTar(char *url, char *destina free(url); return 1; // Eventually make a retry loop } - else if(ret == 2){ - fprintf(stderr, "Output directory \"%s\" does not exist!\n",destinationPath); - free(url); - return 3; - } } else{ fprintf(stderr, "Tar already exists! Download cancelled.\n"); @@ -477,14 +472,17 @@ int unpackJob(char *outdir, char *pathto } -void prepareJobPaths(int jobnum, int framenum, char *outputExt, char *datadir, char **urltoTar,char **pathtoTar,char **pathtoJob, char **pathtoJobfile,char **urltoOutput,char **pathtoOutput, char **pathtoOutdir) +void prepareJobPaths(int jobnum, int framenum, char *outputExt, char *datadir, char **urltoTar,char **pathtoTar,char **pathtoTardir,char **pathtoJob, char **pathtoJobfile,char **urltoOutput,char **pathtoOutput, char **pathtoOutdir) { // Variable Preparation char *jobdatapath; _distren_asprintf(&jobdatapath, "job%d", jobnum); _distren_asprintf(urltoTar, "http://data.distren.org/job%d/job%d.tar.gz", jobnum, jobnum); // Prepares URL to download from _distren_asprintf(pathtoTar, "%s/%s/job%d.tar.gz", datadir, jobdatapath, jobnum); // Prepares destination to save to + _distren_asprintf(pathtoTardir, "%s/%s/", datadir, jobdatapath); // Prepares destination to save to + _distren_asprintf(pathtoJob, "%s/%s/", datadir, jobdatapath); + _distren_asprintf(pathtoJobfile, "%s/%s/job.blend", datadir, jobdatapath ); // Prepares the path to the jobfile _distren_asprintf(urltoOutput, "http://distren.org/slaveUpload.php"); // Prepares the URL where output is posted _distren_asprintf(pathtoOutput, "%s/%s/output/job%d-frame%d.%s", datadir, jobdatapath, jobnum, framenum, outputExt ); @@ -646,7 +644,7 @@ struct _web_memorystruct _web_getrequest curl_global_cleanup(); if(!strncmp(chunk.memory, "ERROR", 5)) - fprintf(stderr, "Web request returned error!\n"); + fprintf(stderr, "Server request returned error %s!\n", chunk.memory); return chunk; // 0 is OK, 1 is 404 or other error } diff --git a/src/server/slavefuncs.h b/src/server/slavefuncs.h --- a/src/server/slavefuncs.h +++ b/src/server/slavefuncs.h @@ -49,7 +49,7 @@ int job_build_path(char *filename, unsig int downloadTar(char *url, char *destinationPath); int uploadOutput(char *pathtoOutput, char *urltoOutput, int jobnum, int framenum, int slavekey); int unpackJob(char *outdir, char *pathtoTar); -void prepareJobPaths(int jobnum, int framenum, char *outputExt, char *datadir, char **urltoTar,char **pathtoTar,char **pathtoJob, char **pathtoJobfile,char **urltoOutput,char **pathtoOutput, char **pathtoOutdir); +void prepareJobPaths(int jobnum, int framenum, char *outputExt, char *datadir, char **urltoTar,char **pathtoTar,char **pathtoTardir,char **pathtoJob, char **pathtoJobfile,char **urltoOutput,char **pathtoOutput, char **pathtoOutdir); int checkUsername(char *username); void slaveTest();