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 |
|
|
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 |
|
|
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 |
|
|