wlandau / crew

A distributed worker launcher
https://wlandau.github.io/crew/
Other
129 stars 4 forks source link

Crew worker hook #184

Closed multimeric closed 2 months ago

multimeric commented 2 months ago

Prework

Proposal

Frequently I want the ability to monitor crew workers, for example by running strace. However, crew doesn't seem to provide a hook for doing this.

I propose a new argument to the controller functions such as crew_controller_local() called something like worker_hook, which is a function that takes the processx process object. The hook would run as part of the worker initialisation. This would allow me to set up appropriate monitoring.

For example:

controller <- crew_controller_local(
    worker_hook = function(process){
        pid <- process$get_pid()
        system2("strace", c("-p", pid), stdout="strace_log.txt")
    }
)
wlandau commented 2 months ago

Sorry, I feel this level of flexibility is not usually going to be necessary for most use cases. You can get the processx handles from controller$launcher$workers$handle.