/[monit]/monit/control.c
ViewVC logotype

Diff of /monit/control.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by rory, Tue Oct 8 22:44:08 2002 UTC revision 1.5 by rory, Wed Oct 9 00:46:34 2002 UTC
# Line 40  Line 40 
40  static void atomic_control_process(Process_T p, char *action);  static void atomic_control_process(Process_T p, char *action);
41  static void atomic_dcontrol_process(Process_T p, char *action);  static void atomic_dcontrol_process(Process_T p, char *action);
42  static void control_dependant_process(Process_T p, char *action, int daemon);  static void control_dependant_process(Process_T p, char *action, int daemon);
43  Command_T check_script(Process_T p, char *action);  
44    
45  /**  /**
46   *  Methods for controlling processes managed by monit.   *  Methods for controlling processes managed by monit.
# Line 137  void check_process(char *P, char *action Line 137  void check_process(char *P, char *action
137        error("%s: '%s' is already running with pid%d\n", prog, P, pid);        error("%s: '%s' is already running with pid%d\n", prog, P, pid);
138        return;        return;
139      }      }
140        if(! p->start) {
141          error("start: '%s' the start program is not defined\n", p->name);
142          return;
143        }
144    }    }
145    else if(is(action, "stop")) {    else if(is(action, "stop")) {
146      if(! is_process_running(p)) {      if(! is_process_running(p)) {
147        error("%s: '%s' is not running\n", prog, P);        error("%s: '%s' is not running\n", prog, P);
148        return;        return;
149      }      }
150        if(! p->stop) {
151      if(! check_script(p, action)) {        error("stop: '%s' the stop program is not defined\n", p->name);
       error("%s: '%s' the %s program is not defined\n",  
             p->name, action, action);  
152        return;        return;
153      }      }
   
154    }    }
155    
156    control_process(p, action, exist_daemon());    control_process(p, action, exist_daemon());
# Line 230  static void atomic_dcontrol_process(Proc Line 231  static void atomic_dcontrol_process(Proc
231  static void atomic_control_process(Process_T p, char *action) {  static void atomic_control_process(Process_T p, char *action) {
232    
233    log("%s: (%s) %s\n", action, p->name, p->start->arg[0]);    log("%s: (%s) %s\n", action, p->name, p->start->arg[0]);
234        if(is(action, "start")) {
235    spawn(p, check_script(p, action));      spawn(p, p->start);
236      }
237      else if(is(action, "stop")) {
238        spawn(p, p->stop);
239      }
240        
241  }  }
242    
# Line 256  static void control_dependant_process(Pr Line 261  static void control_dependant_process(Pr
261    }    }
262        
263  }  }
   
 /*  
  * Return a pointer to start/stop Command_T object  
  * @param p A Process T object @param action A start/stop action  
  */  
 Command_T check_script(Process_T p, char *action) {  
   
   Command_T c = NULL;  
   
   if(is(action, "start")) {  
     c= p->start;  
   }  
   else if(is(action, "stop")) {  
     c= p->stop;  
   }  
     
   return c;  
   
 }  

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26