Changeset - 5964e275c410
[Not reviewed]
default
0 4 0
Nathan Brink (binki) - 16 years ago 2009-12-12 17:03:42
ohnobinki@ohnopublishing.net
slave: reorganize vars, correct config gathering, error handling
4 files changed with 62 insertions and 38 deletions:
0 comments (0 inline, 0 general)
etc/distrenslave.conf.in
Show inline comments
 
@@ -2,6 +2,7 @@ slave
 
{
 
  username = "!username"
 
  datadir = "@LOCALSTATEDIR@/@PACKAGE@"
 
  hostname = "protofusion.org"
 
}
 

	
 
include("distrencommon.conf")
 
\ No newline at end of file
 
include("distrencommon.conf")
src/server/slave.c
Show inline comments
 
@@ -35,9 +35,51 @@
 
int main(int argc, char *argv[])
 
{
 
  char curopt;
 

	
 
  int tmp;
 

	
 
  char *datadir;
 
  char *server;
 
  char *username;
 
  cfg_opt_t myopts[] = {
 
    CFG_SIMPLE_STR("username", &username),
 
    CFG_SIMPLE_STR("datadir", &datadir),
 
    CFG_SIMPLE_STR("server", &server),
 
    CFG_END()
 
  };
 
  cfg_t * my_cfg;
 

	
 
  struct options_common *commonopts;
 

	
 
  int jobnum = 0;
 
  int framenum = 0;
 

	
 
  char *urltoTar;      /* Full URL to the server-side location of job#.tgz */
 
  char *pathtoTar;     /* Full path to the location of the job#.tgz */
 

	
 
  while(-1 != (curopt = getopt(argc, argv, "u:h")))
 
  char *urltoOutput;   /* Full URL where output is posted */
 
  char *pathtoJobfile; /* Full path to the job's main file */
 
  char *pathtoXml;     /* Full path to the job's xml file */
 
  char *pathtoOutput;  /* Full path to the output (rendered) file */
 
  char *outputExt;     /* Output Extension (e.g., JPG) */
 

	
 
  char *tarcmd;        /* Command to run for tar. Migrate to libtar sometime */
 
  char *outdir;        /* Output Directory for tar */
 
  char *jobdatapath;   /* Path to job data */
 

	
 
  struct distrenjob *myjob; /* Structure to hold data gathered from the XML file */
 

	
 
  struct remoteio *comm_slave;
 

	
 
  /**
 
     initializations
 
  */
 
  datadir = NULL;
 
  server = NULL;
 
  username = NULL;
 

	
 

	
 
  while(((char)-1) != (curopt = getopt(argc, argv, "u:h")))
 
     {
 
       if(curopt == ':')
 
         {
 
@@ -63,15 +105,6 @@ int main(int argc, char *argv[])
 
     }
 

	
 
  /* Get conf data */
 
  char *datadir;
 
  cfg_t * my_cfg;
 
  cfg_opt_t myopts[] = {
 
    CFG_SIMPLE_STR("username", &username),
 
    CFG_SIMPLE_STR("datadir", &datadir),
 
    CFG_END()
 
  };
 
  struct options_common *commonopts;
 
  username = NULL;
 
  options_init(argc, argv, &my_cfg, myopts, "slave", &commonopts);
 

	
 

	
 
@@ -97,31 +130,17 @@ int main(int argc, char *argv[])
 
      }
 

	
 

	
 
  int jobnum = 0;
 
  int framenum = 0;
 

	
 
  char *urltoTar;      /* Full URL to the server-side location of job#.tgz */
 
  char *pathtoTar;     /* Full path to the location of the job#.tgz */
 

	
 
  char *urltoOutput;   /* Full URL where output is posted */
 
  char *pathtoJobfile; /* Full path to the job's main file */
 
  char *pathtoXml;     /* Full path to the job's xml file */
 
  char *pathtoOutput;  /* Full path to the output (rendered) file */
 
  char *outputExt;     /* Output Extension (e.g., JPG) */
 
  fprintf(stderr, "Loading config (fasten your seatbelts for a SEGFAULT :-D )...\n");
 
  
 

	
 
  char *tarcmd;        /* Command to run for tar. Migrate to libtar sometime */
 
  char *outdir;        /* Output Directory for tar */
 
  char *jobdatapath;   /* Path to job data */
 

	
 
  struct distrenjob *myjob; /* Structure to hold data gathered from the XML file */
 

	
 
  struct remoteio_opts *comm_slaveopts = {"ssh"};
 

	
 
  struct execio *remoteExec;
 
  struct remoteio *comm_slave = {0, comm_slaveopts, remoteExec}; /* Structures for remotio */
 

	
 
  fprintf(stderr,"Connecting to server...\n");
 
  remoteio_open(&comm_slave, comm_slaveopts, "protofusion" );
 
  fprintf(stderr, "Connecting to server...\n");
 
  tmp = remoteio_open(&comm_slave, commonopts->remoteio, server);
 
  if(tmp)
 
    {
 
      fprintf(stderr, "Error connecting to server; exitting\n");
 
      return 1;
 
    }
 

	
 
  int haveWork = 0;
 

	
src/server/slavefuncs.c
Show inline comments
 
@@ -36,13 +36,16 @@
 
#include <fcntl.h>
 

	
 

	
 
// Sends the server a single request (see protocol.h)
 
int sendSignal(struct remoteio *rem, int signal){
 
/**
 
   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);
 
  _distren_asprintf(&ssignal, "%d", signal);
 
  while( !remoteio_write(rem, ssignal, strlen(ssignal), &written) )
 
    fprintf(stderr,"Writing...");
 
    fprintf(stderr, "Writing...");
 
  return 0;
 
}
 
/**
src/server/slavefuncs.h
Show inline comments
 
@@ -21,6 +21,7 @@
 
#define _DISTREN_SLAVEFUNCS_H
 

	
 
#include "distrenjob.h"
 
#include "remoteio.h"
 

	
 
#include <libxml/xpath.h>
 
#include <stdio.h>
0 comments (0 inline, 0 general)