161 |
* Check to see if we should try to start/stop service |
* Check to see if we should try to start/stop service |
162 |
* @param P A service name as stated in the config file |
* @param P A service name as stated in the config file |
163 |
* @param action A string describing the action to execute |
* @param action A string describing the action to execute |
164 |
|
* @return TRUE if the service was handled successfully otherwise FALSE |
165 |
*/ |
*/ |
166 |
void check_service(char *P, char *action) { |
void check_service(char *P, char *action) { |
167 |
|
|
180 |
|
|
181 |
if(s->task==TASK_PROCESS && is_process_running(s)) { |
if(s->task==TASK_PROCESS && is_process_running(s)) { |
182 |
|
|
183 |
if(!s->do_validate) { |
if(!s->do_monitor) { |
184 |
|
|
185 |
LOCK(Run.mutex) |
LOCK(Run.mutex) |
186 |
s->do_validate= TRUE; |
s->do_monitor= TRUE; |
187 |
END_LOCK; |
END_LOCK; |
188 |
|
|
189 |
DEBUG("Monitoring enabled -- process %s\n", s->name); |
DEBUG("Monitoring enabled -- process %s\n", s->name); |
220 |
log("%s: Start or stop method not defined -- process %s\n", |
log("%s: Start or stop method not defined -- process %s\n", |
221 |
prog, P); |
prog, P); |
222 |
return; |
return; |
223 |
|
} else { |
224 |
|
log("Trying to restart '%s'\n", s->name); |
225 |
} |
} |
226 |
|
|
227 |
do_depend(s, "stop"); |
do_depend(s, "stop"); |
287 |
} |
} |
288 |
|
|
289 |
LOCK(Run.mutex) |
LOCK(Run.mutex) |
290 |
s->do_validate= TRUE; |
s->do_monitor= TRUE; |
291 |
END_LOCK; |
END_LOCK; |
292 |
|
|
293 |
DEBUG("Monitoring enabled -- process %s\n", s->name); |
DEBUG("Monitoring enabled -- process %s\n", s->name); |
309 |
s->depend_visited= TRUE; |
s->depend_visited= TRUE; |
310 |
|
|
311 |
LOCK(Run.mutex) |
LOCK(Run.mutex) |
312 |
s->do_validate= FALSE; |
s->do_monitor= FALSE; |
313 |
END_LOCK; |
END_LOCK; |
314 |
|
|
315 |
DEBUG("Monitoring disabled -- service %s\n", s->name); |
DEBUG("Monitoring disabled -- service %s\n", s->name); |
385 |
} |
} |
386 |
|
|
387 |
if(!is_process_running(s)) |
if(!is_process_running(s)) |
388 |
log("%s: Warning process '%s' was not started\n", prog, s->name); |
log("failed: to start (%s)\n", s->name); |
389 |
|
|
390 |
} |
} |
391 |
|
|
407 |
} |
} |
408 |
|
|
409 |
if(is_process_running(s)) |
if(is_process_running(s)) |
410 |
log("%s: Warning process '%s' was not stopped\n", prog, s->name); |
log("failed: to stop (%s)\n", s->name); |
411 |
|
|
412 |
} |
} |