Jump to content

Process Manager

- - - - -

  • Please log in to reply
3 replies to this topic

#1
anderk57

anderk57

    Newbie

  • Members
  • Pip
  • 2 posts
I am trying to build a process manager for a simulation server which can be driven over the internet. Each simulation runs in its own process. A new process will be spawned each time the user starts a simulation. The user should be able to start a simulation, stop a simulation, and get the status of a simulation. The simulations can take a very long time, and the "start simulation" call should not block. The "status" of the simulation is printed to stdout by the simulator so this needs to be made available to the user.

My initial design was to fork & exec the simulation, and pipe the results to a file. However, you cannot fork & exec in php inside an apache module. Furthermore, it gets a bit messy in this implementation because there is no processes managing the orphaned simulations, so it is tricky to kill them and count them. It seems a bit difficult to use a standard web server since there is no global state which stores the list of running processes (simulations). Is there a good solution for this?

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
What is the simulation running in?

This sounds like something where I would want to have a page with AJAX calls to trigger the start/stop/etc.

There are a LOT of details missing in your description.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
anderk57

anderk57

    Newbie

  • Members
  • Pip
  • 2 posts
The simulator is written in c++, but It should be modified as little as possible. I prefer to write a wrapper for it and exec the simulator and capture its stdout and make that accessible to the user.

Basically, the wrapper should have an web-accessible API with 3 commands.

1.) start_simulation - which basically forks & execs an instance of the simulator, recording its pid in a table, and piping its stdout to a known buffer. The wrapper should not allow more than 16 instances of the simulator to run on the server. If successful, it returns a simulation code to the user. Otherwise, it returns an error code.

2.) stop simuation - takes the simulation code returned in (1), and kills the associated process.

3.) get_process - takes the simulation code returned in (1), looks up the known buffer which holds the stdout for that process, and returns that information to the user.

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
It sounds like you'll need to create an ISAPI or CGI app to run under Apache for this. I'd start by getting a command-line version of the app working, where it can start/stop the processes and dump the info to stdout. Once that's done, I'd work on getting it running through Apache properly.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users