Changeset 4602
- Timestamp:
- Jul 23, 2005, 9:13:00 PM (21 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 3 added
- 13 edited
-
include/convert.h (modified) (1 diff)
-
include/scheduler.h (modified) (4 diffs)
-
lib.data/convert.c (modified) (2 diffs)
-
pantasks/CheckJobs.c (modified) (5 diffs)
-
pantasks/CheckTasks.c (modified) (2 diffs)
-
pantasks/CheckTimeRanges.c (added)
-
pantasks/ControllerOps.c (modified) (1 diff)
-
pantasks/LocalJob.c (modified) (1 diff)
-
pantasks/Makefile (modified) (3 diffs)
-
pantasks/TaskOps.c (modified) (2 diffs)
-
pantasks/init.c (modified) (4 diffs)
-
pantasks/status.c (modified) (1 diff)
-
pantasks/task.c (modified) (3 diffs)
-
pantasks/task_trange.c (added)
-
pantasks/verbose.c (added)
-
scripts/sched.pro (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/include/convert.h
r2598 r4602 26 26 int dms_format PROTO((char *line, double value)); 27 27 int hh_hm PROTO((double hh, int *hr, double *mn)); 28 int day_to_sec PROTO((char *string, time_t *second)); 29 int hms_to_sec PROTO((char *string, time_t *second)); 28 30 29 31 char *meade_deg_to_str PROTO((double deg)); -
trunk/Ohana/src/opihi/include/scheduler.h
r4576 r4602 26 26 } ControllerStat; 27 27 28 enum {RANGE_ABS, RANGE_DAY, RANGE_WEEK}; 29 28 30 /* socket / pipe communication buffer */ 29 31 typedef struct { … … 34 36 int Nbuffer; 35 37 } IOBuffer; 38 39 typedef struct { 40 time_t start; 41 time_t stop; 42 char type; 43 char keep; 44 } TimeRange; 36 45 37 46 /* a task is a description of the wrapping of a job */ … … 78 87 // keep: FALSE: do not perform action within this time period 79 88 80 typedef struct {81 e_time start;82 e_time stop;83 char type;84 char keep;85 } TimeRange;86 87 89 typedef struct { 88 90 int JobID; /* internal ID for job */ … … 141 143 int CheckTasks (); 142 144 int CheckSystem (); 145 int CheckTimeRanges (TimeRange *ranges, int Nranges); 143 146 int GetJobOutput (char *channel, int pid, IOBuffer *buffer, int Nbytes); 144 147 int CheckControllerJob (Job *job); -
trunk/Ohana/src/opihi/lib.data/convert.c
r2598 r4602 1 1 # include "convert.h" 2 # define _XOPEN_SOURCE /* glibc2 needs this */ 3 # include <time.h> 4 5 char *strptime(const char *s, const char *format, struct tm *tm); 6 2 7 3 8 int hh_hms (double hh, int *hr, int *mn, double *sc) { … … 160 165 161 166 return (status); 167 } 168 169 /***** convert 00:00:00 or 00:00 to 0 - 86400 ****/ 170 int hms_to_sec (char *string, time_t *second) { 171 172 char *p; 173 struct tm time; 174 175 p = strptime (string, "%H:%M:%S", &time); 176 if (p != NULL) goto valid; 177 178 p = strptime (string, "%H:%M", &time); 179 if (p != NULL) goto valid; 180 181 return (FALSE); 182 183 valid: 184 if (*p) return (FALSE); 185 *second = time.tm_hour*3600 + time.tm_min*60 + time.tm_sec; 186 return (TRUE); 187 } 188 189 /***** convert Mon[@00:00:00] or 00:00 to 0 - 86400*7 ****/ 190 int day_to_sec (char *string, time_t *second) { 191 192 char *p; 193 struct tm time; 194 195 bzero (&time, sizeof(time)); 196 p = strptime (string, "%A@%H:%M:%S", &time); 197 if (p != NULL) goto valid; 198 199 p = strptime (string, "%A@%H:%M", &time); 200 if (p != NULL) goto valid; 201 202 p = strptime (string, "%A@%H", &time); 203 if (p != NULL) goto valid; 204 205 p = strptime (string, "%A", &time); 206 if (p != NULL) goto valid; 207 208 return (FALSE); 209 210 valid: 211 if (*p) return (FALSE); 212 *second = time.tm_wday*86400 + time.tm_hour*3600 + time.tm_min*60 + time.tm_sec; 213 return (TRUE); 162 214 } 163 215 -
trunk/Ohana/src/opihi/pantasks/CheckJobs.c
r4452 r4602 14 14 /* check for timeout - only local jobs timeout here */ 15 15 if ((job[0].mode == JOB_LOCAL) && (GetTaskTimer(job[0].start) >= job[0].task[0].timeout_period)) { 16 fprintf (stderr, "timeout on %s\n", job[0].task[0].name);16 if (VerboseMode()) fprintf (stderr, "timeout on %s\n", job[0].task[0].name); 17 17 /* run task[0].timeout macro, if it exists */ 18 18 if (job[0].task[0].timeout != NULL) { … … 30 30 switch (status) { 31 31 case JOB_PENDING: 32 fprintf (stderr, "job %s (%d) pending\n", job[0].task[0].name, job[0].JobID);32 if (VerboseMode()) fprintf (stderr, "job %s (%d) pending\n", job[0].task[0].name, job[0].JobID); 33 33 break; 34 34 35 35 case JOB_BUSY: 36 fprintf (stderr, "job %s (%d) busy\n", job[0].task[0].name, job[0].JobID);36 if (VerboseMode()) fprintf (stderr, "job %s (%d) busy\n", job[0].task[0].name, job[0].JobID); 37 37 break; 38 38 … … 41 41 /* set the stdout and stderr variables with job.stdout, job.stderr */ 42 42 /* XXX this will break on 0 values in output streams */ 43 fprintf (stderr, "job %s (%d) crash\n", job[0].task[0].name, job[0].JobID);43 if (VerboseMode()) fprintf (stderr, "job %s (%d) crash\n", job[0].task[0].name, job[0].JobID); 44 44 set_str_variable ("stdout", job[0].stdout.buffer); 45 45 set_str_variable ("stderr", job[0].stderr.buffer); … … 52 52 53 53 case JOB_EXIT: 54 fprintf (stderr, "job %s (%d) exit\n", job[0].task[0].name, job[0].JobID);54 if (VerboseMode()) fprintf (stderr, "job %s (%d) exit\n", job[0].task[0].name, job[0].JobID); 55 55 set_str_variable ("stdout", job[0].stdout.buffer); 56 56 set_str_variable ("stderr", job[0].stderr.buffer); … … 69 69 70 70 default: 71 fprintf (stderr, "unknown exit status: %d\n", status);71 if (VerboseMode()) fprintf (stderr, "unknown exit status: %d\n", status); 72 72 /** do something more useful here ?? **/ 73 73 break; -
trunk/Ohana/src/opihi/pantasks/CheckTasks.c
r4450 r4602 15 15 if (GetTaskTimer(task[0].last) < task[0].exec_period) continue; 16 16 17 /* need to check if the current time is within valid/invalid periods */ 18 if (!CheckTimeRanges (task[0].ranges, task[0].Nranges)) continue; 19 17 20 SetCurrentTask (task[0].name); 18 fprintf (stderr, "trying task %s\n", task[0].name);19 21 20 22 /* ready to run? : run task.exec macro */ … … 35 37 /* reset timer on task (don't do this if Create/Submit fails)*/ 36 38 gettimeofday (&task[0].last, (void *) NULL); 39 task[0].Njobs ++; 37 40 } 38 41 return (TRUE); -
trunk/Ohana/src/opihi/pantasks/ControllerOps.c
r4573 r4602 339 339 int Nread; 340 340 341 if (!status) return (TRUE); 342 341 343 /* read stdout buffer */ 342 344 Nread = ReadtoIOBuffer (&stdout_buffer, stdout_cntl); -
trunk/Ohana/src/opihi/pantasks/LocalJob.c
r4451 r4602 15 15 pid = fork (); 16 16 if (!pid) { /* must be child process */ 17 fprintf (stderr, "starting local job\n");17 if (VerboseMode()) fprintf (stderr, "starting local job\n"); 18 18 19 19 /* close the other ends of the pipes */ -
trunk/Ohana/src/opihi/pantasks/Makefile
r4573 r4602 31 31 $(SDIR)/CheckSystem.$(ARCH).o \ 32 32 $(SDIR)/CheckTasks.$(ARCH).o \ 33 $(SDIR)/CheckTimeRanges.$(ARCH).o \ 33 34 $(SDIR)/ControllerOps.$(ARCH).o \ 34 35 $(SDIR)/LocalJob.$(ARCH).o \ … … 44 45 $(SDIR)/kill.$(ARCH).o \ 45 46 $(SDIR)/delete.$(ARCH).o \ 47 $(SDIR)/verbose.$(ARCH).o \ 46 48 $(SDIR)/controller.$(ARCH).o \ 47 49 $(SDIR)/controller_host.$(ARCH).o \ … … 53 55 $(SDIR)/task_host.$(ARCH).o \ 54 56 $(SDIR)/task_macros.$(ARCH).o \ 57 $(SDIR)/task_trange.$(ARCH).o \ 55 58 $(SDIR)/task_periods.$(ARCH).o 56 59 -
trunk/Ohana/src/opihi/pantasks/TaskOps.c
r4450 r4602 37 37 void ListTasks () { 38 38 39 int i ;39 int i, valid; 40 40 41 41 for (i = 0; i < Ntasks; i++) { 42 fprintf (stderr, "%-15s %20s\n", tasks[i].name, tasks[i].argv[0]); 42 valid = CheckTimeRanges (tasks[i].ranges, tasks[i].Nranges); 43 if (valid) { 44 fprintf (stderr, "+ "); 45 } else { 46 fprintf (stderr, "- "); 47 } 48 fprintf (stderr, "%-15s %4d %20s\n", tasks[i].name, tasks[i].Njobs, tasks[i].argv[0]); 43 49 } 44 50 return; … … 126 132 tasks[Ntasks].timeout_period = 1.0; 127 133 134 tasks[Ntasks].Nranges = 0; 135 ALLOCATE (tasks[Ntasks].ranges, TimeRange, 1); 136 128 137 /* init task timer (is reset by 'run') */ 129 138 gettimeofday (&tasks[Ntasks].last, (void *) NULL); 139 tasks[Ntasks].Njobs = 0; 130 140 131 141 Ntasks ++; -
trunk/Ohana/src/opihi/pantasks/init.c
r4552 r4602 4 4 int task PROTO((int, char **)); 5 5 int task_host PROTO((int, char **)); 6 int task_trange PROTO((int, char **)); 6 7 int task_macros PROTO((int, char **)); 7 8 int task_command PROTO((int, char **)); … … 12 13 int kill_job PROTO((int, char **)); 13 14 int delete_job PROTO((int, char **)); 15 int verbose PROTO((int, char **)); 14 16 15 17 static Command cmds[] = { … … 17 19 {"task", task, "define a schedulable task"}, 18 20 {"host", task_host, "define host machine for a task"}, 21 {"trange", task_trange, "define valid/invalid time periods for a task"}, 19 22 {"task.exit", task_macros, "define exit macros for a task"}, 20 23 {"task.exec", task_macros, "define pre-exec macro for a task"}, … … 26 29 {"kill", kill_job, "kill job"}, 27 30 {"delete", delete_job, "delete job"}, 31 {"verbose", verbose, "set/toggle verbose mode"}, 28 32 }; 29 33 -
trunk/Ohana/src/opihi/pantasks/status.c
r4552 r4602 3 3 int status_sys (int argc, char **argv) { 4 4 5 if (rl_event_hook == NULL) { 6 fprintf (stderr, "scheduler is stopped\n"); 7 } else { 8 fprintf (stderr, "scheduler is running\n"); 9 } 5 10 ListTasks (); 6 11 ListJobs (); -
trunk/Ohana/src/opihi/pantasks/task.c
r4451 r4602 2 2 # define prompt "> " 3 3 4 enum {TASK_NONE, TASK_EMPTY, TASK_COMMENT, TASK_ END, TASK_HOST, TASK_COMMAND, TASK_PERIODS, TASK_EXIT, TASK_EXEC};4 enum {TASK_NONE, TASK_EMPTY, TASK_COMMENT, TASK_NMAX, TASK_TRANGE, TASK_END, TASK_HOST, TASK_COMMAND, TASK_PERIODS, TASK_EXIT, TASK_EXEC}; 5 5 6 6 int task (int argc, char **argv) { … … 68 68 69 69 case TASK_END: 70 /* I need to add in a test here to see if all task elements 71 have been defined. delete the task if not */ 70 72 free (input); 71 73 return (TRUE); 72 74 break; 73 75 76 case TASK_TRANGE: 77 case TASK_NMAX: 74 78 case TASK_HOST: 75 79 case TASK_EXIT: … … 104 108 if (!strcasecmp (command, "END")) hash = TASK_END; 105 109 if (!strcasecmp (command, "HOST")) hash = TASK_HOST; 110 if (!strcasecmp (command, "NMAX")) hash = TASK_NMAX; 111 if (!strcasecmp (command, "TRANGE")) hash = TASK_TRANGE; 106 112 if (!strcasecmp (command, "COMMAND")) hash = TASK_COMMAND; 107 113 if (!strcasecmp (command, "PERIODS")) hash = TASK_PERIODS; -
trunk/Ohana/src/opihi/scripts/sched.pro
r4462 r4602 3 3 4 4 task test 5 command sched.test5 command date 6 6 periods -poll 1.0 7 periods -exec 2.0 8 periods -timeout 8.0 9 # host local 10 host localhost 7 periods -exec 5.0 8 periods -timeout 10.0 9 trange 07:09 07:10 10 trange -exclude 07:09:30 07:09:45 11 host local 12 # host localhost 11 13 # local is default 12 14 13 15 task.exec 14 echo "starting job sched.test"16 # echo "starting job sched.test" 15 17 end 16 18
Note:
See TracChangeset
for help on using the changeset viewer.
