Changeset - b6511767dab2
[Not reviewed]
default
0 3 0
Ethan Zonca (ethanzonca) - 15 years ago 2010-05-28 17:22:40
e@ethanzonca.com
Added additional debug if's to make output cleaner
3 files changed with 20 insertions and 8 deletions:
0 comments (0 inline, 0 general)
etc/distrenslave.conf.in
Show inline comments
 
slave
 
{
 
  username = "!username"
 
  datadir = "@LOCALSTATEDIR@/@PACKAGE@"
 
  server = "protofusion"
 
  hostname = "protofusion.org"
 
}
 

	
 
include("distrencommon.conf")
src/server/simpleslave.c
Show inline comments
 
@@ -26,13 +26,14 @@
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <string.h>
 
#include <sys/stat.h>
 
#include <unistd.h>
 

	
 
#define DEBUG 1
 
#define DEBUG 0
 

	
 

	
 
int main(int argc, char *argv[])
 
{
 
  char *datadir;
 
  char *server;
 
  char *username;
 
@@ -138,13 +139,13 @@ 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;
 

	
 
  // Temporary for uncomressed testing
 
  // Temporary for uncompressed testing
 
  char *urltoJobfile;
 

	
 
  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 *pathtoRenderOutput; /* Contains blender framenum placeholder */
src/server/slavefuncs.c
Show inline comments
 
@@ -38,12 +38,13 @@
 
#include <stdlib.h>
 
#include <sys/stat.h>
 
#include <fcntl.h>
 

	
 
#include <time.h>
 

	
 
#define DEBUG 0
 
/**
 
   Sends the server a single request (see protocol.h)
 
*/
 
int sendSignal(struct remoteio *rem, char signal)
 
{
 
  size_t written;
 
@@ -186,13 +187,14 @@ CURLcode curlpost(char *filename, char *
 
  static const char buf[] = "Expect:";
 

	
 
  char *sjobnum;
 
  char *sframenum;
 
  char *sslavekey;
 

	
 
  fprintf(stderr,"Uploading to %s\n", url);
 
  if(DEBUG)
 
    fprintf(stderr,"Uploading to %s\n", url);
 

	
 
  _distren_asprintf(&sjobnum,"%d",jobnum);
 
  _distren_asprintf(&sframenum,"%d",framenum);
 
  _distren_asprintf(&sslavekey,"%d",slavekey);
 

	
 
  curl_global_init(CURL_GLOBAL_ALL);
 
@@ -312,30 +314,34 @@ 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", input, "-o", output, "-f", frame_str, "-t", "0", (char *)NULL }; // arguments for blender
 

	
 
  fprintf(stderr,"Preparing to execute command: %s -b %s -o %s -f %s\n", command, input, output, frame_str);
 
  if(DEBUG)
 
    fprintf(stderr,"Preparing to execute command: %s -b %s -o %s -f %s\n", command, input, output, frame_str);
 

	
 
  char buf[20];
 
  struct execio *testrem;
 
  size_t readlen;
 

	
 
  fprintf(stderr,"Executing: %s\n", frame_str);
 
  if(DEBUG)
 
    fprintf(stderr,"Executing: %s\n", frame_str);
 

	
 
  ret = execio_open(&testrem, command, cmd);
 
  if(ret)
 
    {
 
      fprintf(stderr, "error running blender\n");
 
      fprintf(stderr, "Error running blender\n");
 
      return 1;
 
    }
 
  buf[19] = '\0';
 
  while(!execio_read(testrem, buf, 19, &readlen))
 
    {
 
       buf[readlen] = '\0';
 
       fprintf(stderr, "read \"%s\"\n", buf);
 
       if(DEBUG)
 
         fprintf(stderr, "read \"%s\"\n", buf);
 
    }
 
  execio_close(testrem);
 
  free(frame_str);
 
  return ret;
 
}
 

	
 
@@ -406,13 +412,17 @@ int downloadTar(char *url, char *destina
 

	
 

	
 
int uploadOutput(char *pathtoOutput, char *urltoOutput, int jobnum, int framenum, int slavekey){
 
  //fprintf(stderr,"Uploading output %s to url %s for job %d and frame %d for slavekey %d", pathtoOutput, urltoOutput, jobnum, framenum, slavekey);
 
  if( !curlpost(pathtoOutput, urltoOutput, jobnum, framenum, slavekey)) // Uploads output
 
    {
 
      fprintf(stderr,"Upload successful, removing old output...\n");
 
      if(DEBUG)
 
        fprintf(stderr,"Upload successful, removing old output...\n");
 
      else
 
        fprintf(stderr,"Upload completed\n");
 

	
 
      remove(pathtoOutput); // Delete the file after its uploaded
 
      return 0;
 
    }
 
  else
 
    {
 
      fprintf(stderr,"Upload failed. Check your network connection. Retrying upload...\n");
0 comments (0 inline, 0 general)