353 |
|
|
354 |
if(P) { |
if(P) { |
355 |
if(! IS(P, "all")) { |
if(! IS(P, "all")) { |
356 |
if(exist_daemon()) { |
control_process(P, "start"); |
|
d_check_service(P, "start"); |
|
|
} else { |
|
|
check_service(P, "start"); |
|
|
} |
|
357 |
} else { |
} else { |
|
|
|
358 |
if(Run.mygroup) |
if(Run.mygroup) |
359 |
control_group(Run.mygroup, "start"); |
control_group(Run.mygroup, "start"); |
360 |
else |
else |
361 |
control("start"); |
control("start"); |
362 |
} |
} |
363 |
} else { |
} else { |
364 |
goto error; |
goto error; |
368 |
|
|
369 |
if(P) { |
if(P) { |
370 |
if(! IS(P, "all")) { |
if(! IS(P, "all")) { |
371 |
if(exist_daemon()) { |
control_process(P, "stop"); |
|
d_check_service(P, "stop"); |
|
|
} else { |
|
|
check_service(P, "stop"); |
|
|
} |
|
372 |
} else { |
} else { |
373 |
if(Run.mygroup) |
if(Run.mygroup) |
374 |
control_group(Run.mygroup, "stop"); |
control_group(Run.mygroup, "stop"); |
375 |
else |
else |
376 |
control("stop"); |
control("stop"); |
377 |
} |
} |
378 |
} else { |
} else { |
379 |
goto error; |
goto error; |
383 |
|
|
384 |
if(P) { |
if(P) { |
385 |
if(! IS(P, "all")) { |
if(! IS(P, "all")) { |
386 |
if(exist_daemon()) { |
control_process(P, "monitor"); |
|
d_check_service(P, "monitor"); |
|
|
} else { |
|
|
check_service(P, "monitor"); |
|
|
} |
|
387 |
} else { |
} else { |
388 |
if(Run.mygroup) |
if(Run.mygroup) |
389 |
control_group(Run.mygroup, "monitor"); |
control_group(Run.mygroup, "monitor"); |
390 |
else |
else |
391 |
control("monitor"); |
control("monitor"); |
392 |
} |
} |
393 |
} else { |
} else { |
394 |
goto error; |
goto error; |
398 |
|
|
399 |
if(P) { |
if(P) { |
400 |
if(! IS(P, "all")) { |
if(! IS(P, "all")) { |
401 |
if(exist_daemon()) { |
control_process(P, "unmonitor"); |
|
d_check_service(P, "unmonitor"); |
|
|
} else { |
|
|
check_service(P, "unmonitor"); |
|
|
} |
|
402 |
} else { |
} else { |
403 |
if(Run.mygroup) |
if(Run.mygroup) |
404 |
control_group(Run.mygroup, "unmonitor"); |
control_group(Run.mygroup, "unmonitor"); |
405 |
else |
else |
406 |
control("unmonitor"); |
control("unmonitor"); |
407 |
} |
} |
408 |
} else { |
} else { |
409 |
goto error; |
goto error; |
410 |
} |
} |
411 |
|
|
|
} else if(IS(action, "reload")) { |
|
|
|
|
|
log("Reinitializing monit daemon\n", prog); |
|
|
kill_daemon(SIGHUP); |
|
|
|
|
412 |
} else if(IS(action, "restart")) { |
} else if(IS(action, "restart")) { |
413 |
|
|
414 |
if(P) { |
if(P) { |
415 |
if(! IS(P, "all")) { |
if(! IS(P, "all")) { |
416 |
if(! exist_service(P)) { |
control_process(P, "restart"); |
|
|
|
|
log("%s: Cannot restart service '%s' -- not found in %s\n", |
|
|
prog, P, Run.controlfile); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if(exist_daemon()) { |
|
|
d_check_service(P, "restart"); |
|
|
} else { |
|
|
check_service(P, "restart"); |
|
|
} |
|
|
|
|
417 |
} else { |
} else { |
|
|
|
418 |
if(Run.mygroup) |
if(Run.mygroup) |
419 |
control_group(Run.mygroup, "restart"); |
control_group(Run.mygroup, "restart"); |
420 |
else |
else |
421 |
control("restart"); |
control("restart"); |
422 |
} |
} |
423 |
} else { |
} else { |
424 |
goto error; |
goto error; |
425 |
} |
} |
426 |
|
|
427 |
|
} else if(IS(action, "reload")) { |
428 |
|
|
429 |
|
log("Reinitializing monit daemon\n", prog); |
430 |
|
kill_daemon(SIGHUP); |
431 |
|
|
432 |
} else if(IS(action, "status")) { |
} else if(IS(action, "status")) { |
433 |
|
|
434 |
if(Run.mygroup) { |
if(Run.mygroup) { |
449 |
|
|
450 |
error: |
error: |
451 |
log("%s: invalid argument -- %s (-h will show valid arguments)\n", |
log("%s: invalid argument -- %s (-h will show valid arguments)\n", |
452 |
prog, action); |
prog, action); |
453 |
exit(1); |
exit(1); |
454 |
|
|
455 |
} |
} |