diff --git a/etc/distrendaemon.conf b/etc/distrendaemon.conf --- a/etc/distrendaemon.conf +++ b/etc/distrendaemon.conf @@ -3,7 +3,7 @@ */ daemon { - datadir = "/home/ohnobinki/var/distren" + datadir = "/home/ethanzonca/var/distren" render_types = {"povray", "blender", "inkscape", "imagemagick", "dcraw"} } @@ -12,6 +12,6 @@ include("distrencommon.conf") listen { type = "unix" - path = "/home/ohnobinki/var/run/distrend.sock" + path = "/home/ethanzonca/var/run/distrend.sock" port = "0770" } diff --git a/etc/distrenslave.conf b/etc/distrenslave.conf --- a/etc/distrenslave.conf +++ b/etc/distrenslave.conf @@ -1,7 +1,7 @@ slave { username = "!username" - datadir = "/home/ohnobinki/var/distren" + datadir = "/home/ethanzonca/var/distren" } include("distrencommon.conf") diff --git a/src/common/protocol.h b/src/common/protocol.h --- a/src/common/protocol.h +++ b/src/common/protocol.h @@ -60,5 +60,6 @@ enum distren_request_type DISTREN_REQUEST_RENDERFRAME = 8, DISTREN_REQUEST_DONEFRAME = 9, DISTREN_REQUEST_PROGRESS = 10, /*< tells another server of the progress of the first server's work at rendering */ + DISTREN_REQUEST_GETWORK = 11, }; diff --git a/src/server/slave.c b/src/server/slave.c --- a/src/server/slave.c +++ b/src/server/slave.c @@ -30,9 +30,10 @@ #include #include + + int main(int argc, char *argv[]) { - char curopt; char *username; @@ -114,16 +115,26 @@ int main(int argc, char *argv[]) struct distrenjob *myjob; /* Structure to hold data gathered from the XML file */ + struct remoteio *comm_slave; /* Structures for remotio */ + struct remoteio_opts *comm_slaveoptions; + + fprintf(stderr,"Connecting to server...\n"); + remoteio_open(&comm_slave, comm_slaveoptions, "protofusion" ); + int haveWork = 0; while(1) { - tell_the_server(0); // Give me some work! + // request work + fprintf(stderr,"Requesting work...\n"); + sendSignal(comm_slave, DISTREN_REQUEST_GETWORK); /* If we got a frame */ if(haveWork) { + + fprintf(stderr,"Got work from server...\n"); /* @TODO: Add remotio hooks */ // 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 */ @@ -150,7 +161,7 @@ int main(int argc, char *argv[]) free(urltoTar); } else { - fprintf(stderr, "Downloading job data from server failed. Check your network connection.\n"); + fprintf(stderr, "Downloading job data from %s failed. Check your network connection.\n",urltoTar); return 1; // Eventually make a retry loop } } @@ -158,7 +169,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Using cached job file...\n"); _distren_asprintf(&outdir, "/tmp/distren/job%d", jobnum); - mkdir("/tmp/distren", 0750); /* @TODO: Change to tmpdir once it exists */ + mkdir("/tmp/distren", 0750); /* @FIXME: Change to tmpdir once it exists */ mkdir(outdir, 0750); _distren_asprintf(&tarcmd, "tar -xvf \"%s\" -C \"%s\"", pathtoTar, outdir); /* @TODO:Use a lib here! */ @@ -178,7 +189,7 @@ int main(int argc, char *argv[]) } else { - fprintf(stderr, "I think the XML craziness may have failed, so I'll terminate just for fun.\n"); + fprintf(stderr, "XML job data parsing has failed. Please contact a developer, or try again.\n"); return 1; } @@ -191,13 +202,13 @@ int main(int argc, char *argv[]) /* Execute blender */ if(exec_blender(pathtoJobfile, pathtoOutput, framenum)) { - fprintf(stderr,"Error running Blender. Check your installation and/or your PATH."); + fprintf(stderr,"Error running Blender. Check your installation and/or your PATH.\n"); return 1; } free(pathtoJobfile); /* Post-execution */ - fprintf(stderr, "Finished frame %d in job %d, uploading...", framenum, jobnum); + fprintf(stderr, "Finished frame %d in job %d, uploading...\n", framenum, jobnum); if( !curlpost(pathtoOutput, urltoOutput)) // Uploads output { fprintf(stderr,"Upload successful, removing old output...\n"); @@ -205,11 +216,11 @@ int main(int argc, char *argv[]) } else { - fprintf(stderr,"Upload failed. Check your network connection. Trying again..."); - int tries=0; - while(tries<10 && curlpost(pathtoOutput, urltoOutput)) + fprintf(stderr,"Upload failed. Check your network connection. Retrying upload...\n"); + int tries=1; + while(tries<=10 && curlpost(pathtoOutput, urltoOutput)) { - fprintf(stderr, "Upload failed. Trying again in 10 seconds... (attempt %d of 10)", tries); + fprintf(stderr, "Upload failed. Trying again in 10 seconds... (attempt %d of 10)\n", tries); tries++; sleep(10); } @@ -218,7 +229,10 @@ int main(int argc, char *argv[]) free(urltoOutput); free(pathtoOutput); - tell_the_server(DISTREN_REQUEST_DONEFRAME); /* Tells the server that it's done rendering, and upload is done */ + // Tell the server that rendering and upload are complete + // sendServer(DISTREN_REQUEST_DONEFRAME); + sendSignal(comm_slave, DISTREN_REQUEST_DONEFRAME); + } else fprintf(stderr,"Nothing to do. Idling...\n"); @@ -233,5 +247,9 @@ int main(int argc, char *argv[]) sleep(5); // Poll 5 seconds. @TODO: Remove all polling } + + fprintf(stderr,"Closing connection to server...\n"); + remoteio_close(comm_slave); + return 0; } diff --git a/src/server/slavefuncs.c b/src/server/slavefuncs.c --- a/src/server/slavefuncs.c +++ b/src/server/slavefuncs.c @@ -21,6 +21,7 @@ #include "distrenjob.h" #include "execio.h" #include "protocol.h" +#include "remoteio.h" #include "slavefuncs.h" #include @@ -35,7 +36,14 @@ #include - +// Sends the server a single request (see protocol.h) +int sendSignal(struct remoteio *rem, int signal){ + size_t written; + char *ssignal; + _distren_asprintf(&ssignal,"%d",signal); + remoteio_write(rem, ssignal, strlen(ssignal), &written); + return 0; +} /** utility function for XPath-ish stuff: */ @@ -70,10 +78,6 @@ int delete_jobdata(int jobnum, char *dat return 0; } -/** Stub @TODO: Replace with remotio */ -void tell_the_server(int stuff){ -} - /** Function referenced by curlget() to write data to disk. */ size_t curl_writetodisk(void *ptr, size_t size, size_t nmemb, FILE *stream) { diff --git a/src/server/slavefuncs.h b/src/server/slavefuncs.h --- a/src/server/slavefuncs.h +++ b/src/server/slavefuncs.h @@ -25,9 +25,11 @@ #include #include + +struct msg; +int sendSignal(struct remoteio *rem, int signal); xmlNodePtr xml_quickxpath(xmlXPathContextPtr xpathctxt, xmlChar *path); int software_updatecheck(); -void tell_the_server(int stuff); int delete_jobdata(int jobnum, char *datadir); size_t curl_writetodisk(void *ptr, size_t size, size_t nmemb, FILE *stream); int curlget(char *url, char *out);