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

Diff of /monit/control.c

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

revision 1.60 by chopp, Wed Aug 13 22:18:42 2003 UTC revision 1.61 by hauk, Sun Aug 17 02:21:21 2003 UTC
# Line 190  void check_service(char *P, char *action Line 190  void check_service(char *P, char *action
190    
191    if(IS(action, "start")) {    if(IS(action, "start")) {
192            
193      if(s->type==TYPE_PROCESS && is_process_running(s)) {      if(!s->do_monitor) {
194          
195        if(!s->do_monitor) {        LOCK(Run.mutex)
   
         LOCK(Run.mutex)  
196            s->do_monitor= TRUE;            s->do_monitor= TRUE;
197          END_LOCK;        END_LOCK;
198          
199          DEBUG("Monitoring enabled -- process %s\n", s->name);        DEBUG("Monitoring enabled -- process %s\n", s->name);
   
       }  
200    
201        }
202      
203        if(s->type==TYPE_PROCESS && is_process_running(s)) {
204        return;        return;
205      }      }
206            
# Line 293  static void do_start(Service_T s) { Line 292  static void do_start(Service_T s) {
292      }      }
293    }    }
294        
295    if(s->start && (s->type==TYPE_PROCESS || !is_process_running(s))) {    if(s->start && (s->type!=TYPE_PROCESS || !is_process_running(s))) {
296      int status;      int status;
297      pthread_t thread;      pthread_t thread;
298      log("start: (%s) %s\n", s->name, s->start->arg[0]);      log("start: (%s) %s\n", s->name, s->start->arg[0]);
299      spawn(s, s->start);      spawn(s, s->start);
300      status= pthread_create(&thread, NULL, wait_start, s);      if(s->type==TYPE_PROCESS) {
301      if(status != 0) {        /* We only wait for a process type, other service types does not
302        log("Warning: Failed to create the start controller thread. "         * have a pid file to watch */
303            "Thread error -- %s.\n", strerror(status));        status= pthread_create(&thread, NULL, wait_start, s);
304          if(status != 0) {
305            log("Warning: Failed to create the start controller thread. "
306                "Thread error -- %s.\n", strerror(status));
307          }
308      }      }
309    }    }
310    
# Line 337  static int do_stop(Service_T s) { Line 340  static int do_stop(Service_T s) {
340    /* Reset the proc info object in case of a later restart */    /* Reset the proc info object in case of a later restart */
341    memset(s->procinfo, 0, sizeof *(s->procinfo));    memset(s->procinfo, 0, sizeof *(s->procinfo));
342        
343    if(s->stop && (s->type==TYPE_PROCESS || is_process_running(s))) {    if(s->stop && (s->type!=TYPE_PROCESS || is_process_running(s))) {
344      log("stop: (%s) %s\n", s->name, s->stop->arg[0]);      log("stop: (%s) %s\n", s->name, s->stop->arg[0]);
345      spawn(s, s->stop);      spawn(s, s->stop);
346        
347      return wait_stop(s);      if(s->type==TYPE_PROCESS) {
348          /* Only wait for process service types */
349          return wait_stop(s);
350        }
351            
352    }    }
353    

Legend:
Removed from v.1.60  
changed lines
  Added in v.1.61

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