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

Diff of /monit/control.c

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

revision 1.93 by martinp, Sun Apr 10 23:30:20 2005 UTC revision 1.94 by martinp, Mon Apr 11 22:27:53 2005 UTC
# Line 145  void control_service(const char *S, cons Line 145  void control_service(const char *S, cons
145    switch(Util_getAction(action)) {    switch(Util_getAction(action)) {
146    
147      case ACTION_START:      case ACTION_START:
148        if(s->type==TYPE_PROCESS && Util_isProcessRunning(s)) {        if(s->type==TYPE_PROCESS) {
149          DEBUG("%s: Process already running -- process %s\n", prog, S);          if(Util_isProcessRunning(s)) {
150          Util_monitorSet(s);            DEBUG("%s: Process already running -- process %s\n", prog, S);
151          return;            Util_monitorSet(s);
152        }            return;
153        if(s->type==TYPE_PROCESS && !s->start) {          }
154          DEBUG("%s: Start method not defined -- process %s\n", prog, S);          if(!s->start) {
155          Util_monitorSet(s);            DEBUG("%s: Start method not defined -- process %s\n", prog, S);
156          return;            Util_monitorSet(s);
157              return;
158            }
159        }        }
160        do_depend(s, ACTION_STOP);        do_depend(s, ACTION_STOP);
161        do_start(s);        do_start(s);
# Line 166  void control_service(const char *S, cons Line 168  void control_service(const char *S, cons
168          Util_monitorUnset(s);          Util_monitorUnset(s);
169          return;          return;
170        }        }
171          /* soft unmonitor and stop: */
172        do_depend(s, ACTION_STOP);        do_depend(s, ACTION_STOP);
173        do_stop(s);        do_stop(s);
174          /* hard unmonitor - will reset all counters and flags: */
175          do_depend(s, ACTION_UNMONITOR);
176          do_unmonitor(s);
177        break;        break;
178    
179      case ACTION_RESTART:      case ACTION_RESTART:
# Line 177  void control_service(const char *S, cons Line 183  void control_service(const char *S, cons
183          return;          return;
184        }        }
185        log("'%s' trying to restart\n", s->name);        log("'%s' trying to restart\n", s->name);
186          /* don't unmonitor the service - keep the start counters state */
187        do_depend(s, ACTION_STOP);        do_depend(s, ACTION_STOP);
188        if(do_stop(s)) {        if(do_stop(s)) {
189          /* Only start if stop succeeded */          /* Only start if stop succeeded */
# Line 275  static void do_start(Service_T s) { Line 282  static void do_start(Service_T s) {
282        }        }
283      }      }
284    }    }
   
285    Util_monitorSet(s);    Util_monitorSet(s);
   
286  }  }
287    
288    
# Line 294  static int do_stop(Service_T s) { Line 299  static int do_stop(Service_T s) {
299      return TRUE;      return TRUE;
300    
301    s->depend_visited= TRUE;    s->depend_visited= TRUE;
302    
303    Util_monitorUnset(s);    /* do soft unmonitor - start counter state is kept, in the case that
304         the process should be definitely stopped, Util_monitorUnset should
305         be called after do_stop */
306      if(s->monitor != MONITOR_NOT)
307      {
308        s->monitor= MONITOR_NOT;
309        DEBUG("Monitoring disabled -- service %s\n", s->name);
310      }
311    
312    if(s->stop && (s->type!=TYPE_PROCESS || Util_isProcessRunning(s))) {    if(s->stop && (s->type!=TYPE_PROCESS || Util_isProcessRunning(s))) {
313      log("'%s' stop: %s\n", s->name, s->stop->arg[0]);      log("'%s' stop: %s\n", s->name, s->stop->arg[0]);
# Line 308  static int do_stop(Service_T s) { Line 320  static int do_stop(Service_T s) {
320    
321    }    }
322    
323      Util_resetInfo(s);
324    
325    return TRUE;    return TRUE;
326    
327  }  }

Legend:
Removed from v.1.93  
changed lines
  Added in v.1.94

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