# HG changeset patch # User ethanzonca # Date 2009-08-03 00:21:59 # Node ID 7647047dfa9d80624028842267f0675f92799383 # Parent 75a599984bd29392318286072c2af70681de7f15 Psedo-code edit, buggy, needs work. diff --git a/src/server/slave.c b/src/server/slave.c --- a/src/server/slave.c +++ b/src/server/slave.c @@ -25,6 +25,7 @@ #include #include #include +#include "asprintf.h" int slavestatus = 0; // Ugh global vars @@ -106,18 +107,36 @@ options_init(argc,argv,&my_cfg, myopts, /* Somewhat pseudo Rendering code */ -/* - if('slave recieves "start frame#, job#"'){ + +/* These should all be filled by remotio and other code */ +int jobnum; +int framenum; +int slaveget; +int telldone; +int blender_is_running; +char *jobdatapath = "/path/to/job.tgz"; +char *outputpath = "/path/to/output.jpg"; + +char *pathtoblend; // oh, blender-specific horribleness + +// If the slave is getting a frame (fill jobnum, framenum, and slaveget vars when this happens) + if(slaveget ==1){ fprintf(stderr, "Received %d in job %d, preparing to render...",framenum,jobnum); - get('http://distren.protofusion.org/srv/job%d.tgz', jobnum); // use curl + char *jobdataurl; + + + _distren_asprintf(&jobdataurl, "http://protofusion.org/distren/stor/job%d.tgz",jobnum); + + curlget(jobdataurl, jobdatapath); // downloads job data from the url to the path stated + _distren_asprintf(&pathtoblend, "%s/job.blend", jobdatapath ); // @TODO: Fix jobdatapath so it knows where to get the file for real :D exec('tar -xvf job%d.tgz /tmp/distren/job%d',jobnum,jobnum); // somehow - exec_blender("GIVE ME SOME ARGS!"); // (check the args, we'll need to adjust for different output formats, include this in the blendjob struct later) + exec_blender(blendjob, pathtoblend, outputpath, framenum); // So this should grab data from the struct? I have no idea. @TODO: Ohnobinki, we should clear this up. // Consider placing the following in the exec_blender() function while(blender_is_running == 1){ tell_the_server(DISTREN_REQUEST_PROGRESS); fprintf(stderr, "Rendering frame %d in job %d...",framenum,jobnum); - delay(1000); // or not... this should be more event-driven, but should still give a heartbeat to the server + sleep(5); // or not... this should be more event-driven, but should still give a heartbeat to the server } @@ -125,12 +144,14 @@ options_init(argc,argv,&my_cfg, myopts, } if(telldone==1){ fprintf(stderr, "Finished frame %d in job %d, uploading...",framenum,jobnum); - curl_POST("/path/to/output.jpg", "http://protofusion.org/distren/output/job%d",jobnum); + char *outputurl; + _distren_asprintf(&outputurl, "http://protofusion.org/distren/stor/job%d/",jobnum); // Throws the jobnum nicely in the string + curlpost(outputpath, outputurl); // posts the output at outputpath to the server at outputurl tell_the_server(DISTREN_REQUEST_DONEFRAME); // AKA "I'm done rendering that frame you sent me" telldone=0; // Slave now becomes idle, doesn't need to tell the server anything, ssh handles this. } -*/ + return 0; }