diff --git a/omd/packages/check_mk/skel/etc/init.d/ui-job-scheduler b/omd/packages/check_mk/skel/etc/init.d/ui-job-scheduler index 96e1d2ccc4e..784f663ab76 100755 --- a/omd/packages/check_mk/skel/etc/init.d/ui-job-scheduler +++ b/omd/packages/check_mk/skel/etc/init.d/ui-job-scheduler @@ -38,6 +38,45 @@ exit_failure() { exit 1 } +stop_ui_scheduler() { + echo -n 'Stopping ui-job-scheduler...' + if [ -z "$THE_PID" ]; then + exit_successfully 'not running.' + fi + + if ! process_is_running; then + exit_successfully 'not running (PID file orphaned)' + fi + + echo -n "killing $THE_PID..." + if ! kill "$THE_PID" 2>/dev/null; then + exit_successfully 'OK' + fi + + # Signal could be sent + + # Patiently wait for the process to stop + if await_process_stop 60; then + exit_successfully 'OK' + fi + + # Insist on killing the process + force_kill + if await_process_stop 10; then + exit_successfully 'OK' + fi + exit_failure 'failed' +} + +wait_for_background_jobs() { + echo -n "Waiting for background-jobs to finish..." + if cmk-wait-for-background-jobs; then + exit_successfully 'OK' + else + exit_failure "Failed (some were still running)" + fi +} + case "$1" in start) echo -n 'Starting ui-job-scheduler...' @@ -53,40 +92,7 @@ case "$1" in fi ;; stop) - echo -n 'Stopping ui-job-scheduler...' - if [ -z "$THE_PID" ]; then - exit_successfully 'not running.' - fi - - if ! process_is_running; then - exit_successfully 'not running (PID file orphaned)' - fi - - echo -n "killing $THE_PID..." - if ! kill "$THE_PID" 2>/dev/null; then - exit_successfully 'OK' - fi - - # Signal could be sent - - # Patiently wait for the process to stop - if await_process_stop 60; then - exit_successfully 'OK' - fi - - # Insist on killing the process - force_kill - if await_process_stop 10; then - exit_successfully 'OK' - fi - exit_failure 'failed' - - echo -n "Waiting for background-jobs to finish..." - if cmk-wait-for-background-jobs; then - echo "OK" - else - echo "Failed (some were still running)" - fi + (stop_ui_scheduler) && wait_for_background_jobs ;; restart)