in reply to How to efficiently manage bunch of processes

Umm, I may be missing the mark here, but wouldn't the easiest way just be to start them all from a shell/batch script (depending upon system type) ?

Also depending upon what each does, and it sounds like it may be a 3-tier system where some parts are just processing data, these could probably be run as a system service/daemon, and left running, just restarting when you actually change the code. (ie, run and forget, and just start the client/interactive bits, when you need them.)

It's difficult to suggest specific solutions, without knowing more about the nature of the program.

(A third idea, have one part start the other parts, configurably?)

C.

  • Comment on Re: How to efficiently manage bunch of processes

Replies are listed 'Best First'.
Re: Re: How to efficiently manage bunch of processes
by Eyck (Priest) on Mar 19, 2004 at 11:05 UTC
    That's how I'm doing it right now.

    But this way the system behaves like three different, independant apps, this is good - I can stop, start, restart any part of it, and bad - it's three different daemons, and when I hand out maintainance to someone else I need to explain the inner workings of the system - it doesen't behave like a single system to them.

    It's a bit like hmm, say, Oracle database, it consist of various important parts, and I would prefer it to behave more like single daemon, like apache webserver.

    If I would merge this into single binary, that forks itself to handle various tasks, I would loose ability to easily manage those parts. So this is how it would look like with apps split into two parts:

    my $child=fork(); die "Can't fork: $!" unless defined $child; if ($child) { handle_task_one(); } else { handle_task_two(); }
    Looks almost ok... but now with three parts:
    my $child=fork(); die "Can't fork: $!" unless defined $child; if ($child) { handle_task_one(); } else { my $childschild=fork(); die "Can't fork: $!" unless defined $childschild; if ($childschild) { handle_task_two(); } else { handle_task_two(); } }
    Now it becomes unreadable. I got away with it when I created pool of worker 'threads', but with different functions I would prefer my code to look a little better.
      So don't merge it. If you look at an Oracle install, or any other sufficiently large software, you'll see it consists of a whole bunch of executables, DLLs and so on. It just has a single Interface, which starts and stops bits as needed. The argument of needing to explain how it runs to someone else isn't really one, if that's how you've designed it, then thats how it is, describe how it works to them.

      It really does sound as if you need one overall script, which runs the others.. Why fork? Why not just run them using system() or similar? (I assume your three parts already have some external method of communicating). That way you get to keep the code in separate, easily managable scripts.

      Alternatively, you don't need to copy all the code into one script to have it run together, using modules and such will keep the actual code separate, but allow it to act as one. Eg. make a module for one part, do 'use Module;' and 'Module::Run();' to get it started ?

      (Forks are yucky, if you ask me ,)

      C.