DUNE-DAQ / drunc

Dune RUN Control (DRUNC) is the run control for the DUNE experiment
1 stars 1 forks source link

Start the ProcessManager in the unified shell #43

Closed plasorak closed 6 months ago

plasorak commented 6 months ago

With this PR, one doesn't need to have 2 terminal windows open simultaneously to start the drunc-unified-shell, as the shell directly starts the process manager in a multiprocess.Process. To get this to work correctly, there is quite a bit of bookkeeping of the signal that needs to happen (not that on Linux the multiprocess.Process are forks):

  1. I tied the Process Manager's fate to the drunc-unified-shell's main thread by using the code here. This uses magic incantations I don't fully understand, but it works correctly (and is close to a snippet at the top of nanorc's SSHPM), and sends SIGKILL to the forked process when the main gets one.
  2. When an exception gets thrown in the drunc-unified-shell's main, I SIGKILL the forked process, if it exists.
  3. When the main gets a SIGINT (for example, ctrl-c from a user in the shell), this signal gets propagated to the forked process, so the fork needs to catch and ignore that signal in the case it runs with the unified shell.

That's all folks!

plasorak commented 6 months ago

With the last 2 commits, we can now specify

    "command_address": "localhost:0",

In the Process manager json, so that we don't need to assign port ourselves for the process manager server.

TiagoTAlves commented 6 months ago

Once I added the the import statement I tested it and the unified shell worked

TiagoTAlves commented 6 months ago

Also works with K8s pm