Changeset - 6331e72e3889
[Not reviewed]
default
0 4 0
Ethan Zonca (ethanzonca) - 16 years ago 2010-03-14 14:24:02
e@ethanzonca.com
Added more debug info, checks... oddness still going on with unpackjob()
4 files changed with 27 insertions and 16 deletions:
0 comments (0 inline, 0 general)
src/server/simpleslave.c
Show inline comments
 
@@ -106,12 +106,13 @@ int main(int argc, char *argv[])
 
  int jobnum = 0;
 
  int framenum = 0;
 
  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 */
 
  char *pathtoOutdir;  /* Full path to output directory */
 

	
 
  char *pathtoJob; /* Path to job data folder */
 
@@ -137,23 +138,33 @@ int main(int argc, char *argv[])
 
        // jobnum = remoteio_read(jobnum); /* Set jobnum from remoteio (we could use info from struct, but we need this info to download the xmlfile */
 
        // framenum = remoteio_read(jobnum); /* Set framenum from remoteio */
 
        // outputExt = remotio)read(outputExt); /* Set output extension from remotio */
 

	
 
        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");
 
        else if(dlret == 3)
 
          return 0; // ouput dir doesn't exist
 
        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);
 
        mkdir(pathtoOutdir, 0700);
 
        fprintf(stderr,"Marking frame started on server... ");
 
        _web_startframe(slavekey, password, jobnum, framenum);
 
@@ -170,12 +181,13 @@ int main(int argc, char *argv[])
 
        free(pathtoJobfile);
 

	
 
        struct stat buffer;
 
        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{
 
          /* Post-execution */
 
          fprintf(stderr, "Finished frame %d in job %d, uploading...\n", framenum, jobnum);
 
          uploadOutput(pathtoOutput, urltoOutput, jobnum, framenum, slavekey); // @TODO: Handle return value
src/server/slave.c
Show inline comments
 
@@ -112,12 +112,13 @@ int main(int argc, char *argv[])
 
  // Variables needed for main loop
 
  int jobnum = 0;
 
  int framenum = 0;
 
  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 */
 
  char *pathtoOutdir;  /* Full path to output directory */
 

	
 
  char *pathtoJob;     /* Full path to job data folder */
 
@@ -143,13 +144,13 @@ int main(int argc, char *argv[])
 
        // jobnum = remoteio_read(jobnum); /* Set jobnum from remoteio (we could use info from struct, but we need this info to download the xmlfile */
 
        // framenum = remoteio_read(jobnum); /* Set framenum from remoteio */
 
        // outputExt = remotio)read(outputExt); /* Set output extension from remotio */
 

	
 
        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))
 
          return 1;
 

	
 
        unpackJob(datadir, pathtoTar);
src/server/slavefuncs.c
Show inline comments
 
@@ -292,24 +292,24 @@ int exec_blender(char *input, char *outp
 
  char *frame_str;
 
  _distren_asprintf(&frame_str, "%i", frame);
 

	
 
  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;
 
  size_t readlen;
 

	
 
  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';
 
       fprintf(stderr, "read \"%s\"\n", buf);
 
    }
 
  execio_close(testrem);
 
@@ -374,17 +374,12 @@ int downloadTar(char *url, char *destina
 
      }
 
      else if(ret == 1){
 
        fprintf(stderr, "Downloading job data from %s failed. Check your network connection.\n",url);
 
        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");
 
    return 2;
 
  }
 

	
 
@@ -474,20 +469,23 @@ int unpackJob(char *outdir, char *pathto
 
    }
 

	
 
  return 0;
 
}
 

	
 

	
 
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 );
 
   _distren_asprintf(pathtoOutdir, "%s/%s/output", datadir, jobdatapath);
 
   free(jobdatapath);
 
}
 
@@ -643,13 +641,13 @@ struct _web_memorystruct _web_getrequest
 
  }
 

	
 
  /* we're done with libcurl, so clean it up */
 
  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
 

	
 
}
 

	
 
void _web_finishframe(int slavekey, char *slavepass, int jobnum, int framenum){
 
  char *url;
src/server/slavefuncs.h
Show inline comments
 
@@ -46,13 +46,13 @@ void xmlinit();
 
void xmlcleanup();
 
int distren_mkdir_recurse(char *dirname);
 
int job_build_path(char *filename, unsigned int jobnum);
 
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();
 

	
 
/* Simple slave */
 
struct _web_memorystruct;
 
static void *_web_myrealloc(void *ptr, size_t size);
0 comments (0 inline, 0 general)