// // Copyright (C) 2001,2002,2003,2004 Jorge Daza Garcia-Blanes // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 // USA // // // Modifications made by Brian Knudson (brian(at)martian-labs.com) 8/08/2006 // These modifications do the following: // - Submit *only* a General job // - Add options for general type job // - Use only Linux machines // // #include #include #include #include #if defined (__IRIX) #include #else #include #endif // for password stuff #include #include #include "martianSendJob.h" #include "libdrqueue.h" #include "envvars.h" #include "job.h" void usage (void); int main (int argc,char *argv[]) { char owner[64] = "briank"; char jobName[64] = "no_name"; char command[256] = "bad"; char email[256] = "briank@hero.com"; int opt; int cpus_per_machine = -1; int cpus_on_farm = -1; int frameStart = 1; int frameEnd = 100; int frameStep = 1; int depends = 0; int dependid = 0; int mailme = 0; struct job job; struct passwd *pw; presentation(); while ((opt = getopt (argc,argv,"hvo:j:s:e:i:c:m:f:d:a:")) != -1) { switch (opt) { case 'v': // show_version (argv); exit (0); case 'o': sprintf(owner,"%s",optarg); break; case 'j': sprintf(jobName,"%s",optarg); break; case 's': frameStart = atoi(optarg); break; case 'e': frameEnd = atoi(optarg); break; case 'i': frameStep = atoi(optarg); break; case 'c': sprintf(command,"%s",optarg); break; case 'm': cpus_per_machine = atoi(optarg); break; case 'f': cpus_on_farm = atoi(optarg); break; case 'd': depends = 1; dependid = atoi(optarg); break; case 'a': mailme = 1; sprintf(email,"%s",optarg); break; case '?': case 'h': usage(); exit (1); } } if ((argc < 2) || !(strcmp(command,"bad"))){ usage (); exit(1); } set_default_env(); if (!common_environment_check()) { fprintf(stderr,"Error checking the environment: %s\n",drerrno_str()); return 1; } job_init(&job); printf ("owner: %s\n", owner); printf ("jobName: %s\n", jobName); printf ("framestart: %d, frameEnd: %d, step: %d\n", frameStart, frameEnd, frameStep); printf ("command: %s\n", command); if (depends) printf ("depends on job: %d\n",dependid); // job name & command strncpy (job.name,jobName,MAXNAMELEN-1); strncpy (job.cmd,command,MAXCMDLEN-1); // job owner (should remove first line) strncpy (job.owner,owner,MAXNAMELEN-1); if (!(pw = getpwuid(geteuid()))) { strncpy (job.owner,"ERROR",MAXNAMELEN-1); } else { strncpy (job.owner,pw->pw_name,MAXNAMELEN-1); } job.owner[MAXNAMELEN-1] = 0; // job stuff job.frame_start = frameStart; job.frame_end = frameEnd; job.frame_step = frameStep; job.priority = 500; job.block_size = 1; // kind of job job.koj = KOJ_GENERAL; // job.autoRequeue = 1; job.status = JOBSTATUS_WAITING; job.frame_info = NULL; job.limits.os_flags = OSF_LINUX; job.limits.nmaxcpus = (uint16_t)cpus_on_farm; job.limits.nmaxcpuscomputer = (uint16_t)cpus_per_machine; job.limits.memory = 0; strncpy (job.limits.pool,"Default",MAXNAMELEN-1); job.envvars.variables = NULL; job.envvars.nvariables = 0; job.envvars.evshmid = -1; job.flags = 0; if (depends) { job.flags |= JF_JOBDEPEND; job.dependid = dependid; } if (mailme) { job.flags |= JF_MAILNOTIFY; // mail on job.flags |= JF_MNDIFEMAIL; // specific mail (I think) sprintf(job.email,"%s",email); } if (!register_job(&job)) { fprintf(stderr,"Error sending job to the queue\n"); return 1; } fprintf(stderr,"Job sent successfuly to the queue\n"); exit (0); } void presentation (void) { printf("DrQueue - by Jorge Daza García Blanes, Modified by BK\n\n"); } void cleanup (int signum) { exit(0); } void usage (void) { fprintf(stderr,"\nUsage: martianSendJob [options]\n\n"); fprintf(stderr," This program submits a job to the render farm.\n\n"); fprintf(stderr,"Options:\n"); fprintf(stderr," -o owner Owner of the job\n"); fprintf(stderr," -j name Name of the job\n"); fprintf(stderr," -s start Frame number on which to start\n"); fprintf(stderr," -e end Frame number on which to end\n"); fprintf(stderr," -i increment Number of frames to increment (stepsize)\n"); fprintf(stderr," -c command Command to render a frame\n"); fprintf(stderr," -m cpus Max number of cpus per machine\n"); fprintf(stderr," -f cpus Max number of cpus on the farm\n"); fprintf(stderr," -d id This job depends on job \n"); fprintf(stderr," -a address Send email to this address when complete \n"); fprintf(stderr," -v Print version of this program\n"); fprintf(stderr," -h This help screen\n\n\n"); }