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. |
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()); |
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 |
|
|
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; |
|
|
|
|
|
} |
|