X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=scripts%2Fprocesses%2Fprocess_manager.sh;h=48737e471867db33d80ed39a482a704f0ac03b59;hb=8064b3bda39bcb17d8550006a2e99cd9e5cfadee;hp=b9497d8a8e7925e564debf557417ba5673261f03;hpb=3bf79453599d6ed0379a6ba0e88468e2b7d57db0;p=feisty_meow.git diff --git a/scripts/processes/process_manager.sh b/scripts/processes/process_manager.sh index b9497d8a..48737e47 100644 --- a/scripts/processes/process_manager.sh +++ b/scripts/processes/process_manager.sh @@ -6,13 +6,12 @@ # Author : Chris Koeritz # Rights : Copyright (C) 2015-$now by Author # -# Purpose: +# Purpose: # -# Turns Unix format text files into DOS format text files. -# relies on the built-in process management to run a bunch of processes -# in the background, but will limit total number running to a maximum. -# demonstration method at the end of the file shows how to use the -# process managing methods. +# Relies on the built-in process management in bash to run a bunch of +# processes in the background, but will limit total number running to a +# maximum count. There is a demonstration method at the end of the file +# that shows how to use the process management functions. # ############## # This script is free software; you can modify/redistribute it under the terms @@ -20,15 +19,6 @@ # Feel free to send updates to: [ fred@gruntose.com ] ############## -# process manager helper methods for bash. -# -# relies on the built-in process management to run a bunch of processes -# in the background, but will limit total number running to a maximum. -# demonstration method at the end of the file shows how to use the -# process managing methods. -# -# by chris koeritz - #hmmm: revisions desired someday: # + allow number of max processes to be passed in. # + @@ -62,10 +52,10 @@ function nechung() { start_background_action \ 'echo "your nechung oracle pronouncement of the moment..."' \ - '$BINDIR/nechung' + '$FEISTY_MEOW_BINARIES/nechung' } -function login_on_xcg() +function sum_dir() { start_background_action \ 'echo "summing directory output coming up..."' \ @@ -90,17 +80,23 @@ function wait_on_backgrounders() echo "done waiting, background process count is down to $bg_count." } +#hmmm: the demo app here raises some concerns--how do we know the bg count is right? +# what if something died and we didn't check it? +# will the thing that looks at bg count adjust it if there are actually no waiting processes? + # happily launches off different actions as background processes. launcher_demonstrator() { - while true; do + # run a limited number of loops, since we don't want to do this forever. + local loops=50 + while ((loops-- > 0)); do # pick a thing to do. which=$(($RANDOM % 3)) #hmmm: not asynch yet! make it so! case $which in 0) take_inventory;; 1) nechung;; - 2) login_on_xcg;; + 2) sum_dir;; esac # we have reached the limit on processes and need to wait for a few, defined by