Changeset - eabe88569bb3
[Not reviewed]
default
0 2 0
ethanzonca - 16 years ago 2009-07-25 16:49:44

More bugsquashing
2 files changed with 7 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/server/slave.c
Show inline comments
 
@@ -29,24 +29,28 @@
 

	
 
// Provides DISTREN_REQUEST* which is in reality, DISTREN_SEND(signal) in the minds of your average joe
 
#include "protocol.h"
 
#include "options.h" // Confuse, etc.
 
#include <string.h>
 
#include <stdio.h>
 

	
 
int slavestatus = 0; // Ugh global vars
 

	
 
int main(int argc, char *argv[])
 
{
 

	
 
int jobnum;
 
char *jobname;
 
int framenum;
 

	
 
/* Parses arguments, skips if there are no args */
 
	if(argc>1
 
		&& (strcmp("-c", argv[1]) == 0))
 
	{
 
		char *username;
 
		char *email;
 

	
 
		if(argc != 4)
 
		{
 
			fprintf(stderr, "I need more arguments!\n%d is not enough!\n Invoke 'distrenslave -c <username> <emailaddr> to register. \n Already registered? Edit your distrenslave.conf file!'", argc - 1);
 
			return 234;
 
		}
 
@@ -86,28 +90,28 @@ options_init(argc,argv,&my_cfg, myopts, 
 
	if(key == NULL || username == NULL){
 
		fprintf(stderr,"You didn't register! \n Please register (Invoke 'distrenslave -c <username> <emailaddr> to register) \nor add your username to distrenslave.conf");
 
	}
 
	else if(key != NULL || username != NULL){
 
		loginuser(username); // Logs in user to the server
 
	}
 
	else{
 
		fprintf(stderr,"Something is terribly wrong!!!");
 
	}
 

	
 

	
 
	if('slave recieves "start frame#, job#"'){
 
		fprintf(stderr, "Got frame %d in job %d, preparing to render...",frame,job);
 
		fprintf(stderr, "Got frame %d in job %d, preparing to render...",framenum,jobnum);
 
		get('http://distren.protofusion.org/srv/job#.tgz');
 
		exec('tar -xvf job#.tgz /tmp/distren/job#'); // somehow
 
		exec_blender(jobname.blendfile, jobnum.framenum.JPG, jobnum); // (check the args, we'll need to adjust for different output formats, include this in the blendjob struct later)
 
		exec_blender("jobname.blendfile, jobnum.framenum.JPG, jobnum"); // (check the args, we'll need to adjust for different output formats, include this in the blendjob struct later)
 
			while('blender is running'){
 
				slavestatus=1; // really quite pointless now, but why not. Could be nice for logging.
 
				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
 
			}
 
		slavestatus=2; // When done rendering, set this.
 
	}
 
	if(slavestatus==2){
 
		fprintf(stderr, "Finished frame %d in job %d",framenum,jobnum);
 
		slavestatus=0;
 
	}
src/server/slavefuncs.c
Show inline comments
 
@@ -104,25 +104,25 @@ void loginuser(char *username){
 
/* Executors */
 

	
 
/*
 
  It seems that the client will need to know the job number. Is finish_frame going to be on the client or the server? we gotta figure that out!
 
*/
 
void exec_blender(struct blendjob* blendjob, char *input, char *output, int frame)
 
{
 
  char *frame_str;
 
  asprintf(frame,frame_str); // GNU/*nix compatible only, fix before releasing win32, although dll for windows for asprintf exists!
 
  int ret;
 
  char *cmd[] = { "blender", "-b", "-o", output, input, "-f", frame_str, (char *)0 };
 
  ret = execv("/usr/bin/blender", cmd); // This path will be absolute for testing, should be relative to install on production
 
  finish_frame(blendjob, frame);
 
  finish_frame(blendjob, frame); // Is this going to be client-side or server-side?
 
}
 

	
 
/* Update me when the time comes:
 
void exec_luxrender(struct luxjob* luxjob, char *input, char *output, int frame)
 
{
 
  char *frame_str;
 
  asprintf(frame,frame_str);
 
  int ret;
 
  char *cmd[] = { "luxrender", "-b", "-o", output, input, "-f", frame_str, (char *)0 }; // Fix args later
 
  ret = execv("/usr/bin/luxrender", cmd); // Absolute for testing, relative on production
 
  finish_frame(luxjob, frame);
 
}
0 comments (0 inline, 0 general)