Changeset - 5b92d40010bc
[Not reviewed]
default
0 1 0
ethanzonca - 16 years ago 2009-08-03 20:45:44

Minor updates, still contemplating about the best way to make this work
1 file changed with 20 insertions and 17 deletions:
0 comments (0 inline, 0 general)
src/server/slave.c
Show inline comments
 
@@ -106,52 +106,55 @@ options_init(argc,argv,&my_cfg, myopts, 
 
	}
 

	
 

	
 
/* Somewhat pseudo Rendering code */
 

	
 
/* These should all be filled by remotio and other code */
 
int jobnum;
 
int framenum;
 
int slaveget;
 
int telldone;
 
int blender_is_running;
 
int jobnum;   // Filled by the server telling the client what to render
 
int framenum; // same as above
 
int gotframe; // set this to 1 after data for a job is received from the server
 

	
 
int busy = 0;     // Client business 1=busy 0=idle
 

	
 
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);
 
		char *jobdataurl;
 
char *jobdataurl;
 

	
 

	
 
		_distren_asprintf(&jobdataurl, "http://protofusion.org/distren/stor/job%d.tgz",jobnum);
 
// If the slave is getting job info...
 
	if(gotframe ==1){
 
		fprintf(stderr, "Received %d in job %d, preparing to render...",framenum,jobnum);
 

	
 
		curlget(jobdataurl, jobdatapath); // downloads job data from the url to the path stated
 
		_distren_asprintf(&jobdataurl, "http://protofusion.org/distren/stor/job%d.tgz",jobnum); // Throws jobnum in jobdataurl
 

	
 
		curlget(jobdataurl, jobdatapath); // downloads job data from the url to the path stated, @TODO: add a progressbar
 
		_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); // @TODO: How will we do this?
 
		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){
 
			while(busy == 1){
 
				tell_the_server(DISTREN_REQUEST_PROGRESS);
 
				fprintf(stderr, "Rendering frame %d in job %d...",framenum,jobnum);
 
				sleep(5); // or not... this should be more event-driven, but should still give a heartbeat to the server
 
			}
 

	
 
			busy = 2;
 

	
 
		telldone=1; // When done rendering, set this.
 
		busy=1; // When done rendering, set this.
 
	}
 
	if(telldone==1){
 
	// When blender is finished, run this...
 
	if(busy==2){
 
		fprintf(stderr, "Finished frame %d in job %d, uploading...",framenum,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;
 
		busy=0;
 
		// Slave now becomes idle, doesn't need to tell the server anything, ssh handles this.
 
		jobnum =
 
	}
 

	
 

	
 
  return 0;
 
}
0 comments (0 inline, 0 general)