Closed cassaundra closed 10 months ago
Not sure if you're aware but nushell has a par-each
command that runs things in parallel. You might find some insight from there if you don't already know about it.
Implemented as of now. Will refactor more when adding hot reloading and runtime configuration options.
Concurrent tasks are useful for both performance and usecases like running a frontend and backend simultaneously.
Implementation
Usage
Add a
--concurrent
flag to tasks which runs the task without blocking.Implementation
EngineState
would need to be cloned and used for each concurrent task, meaning changes to the global state (e.g. mutating variables) would be isolated to the task. If this is done, it should be done for all tasks for consistency. For that matter, it might be best to either modify the engine state to make all variables immutable, or create a clean engine state altogether.Output handling
For now, tasks output directly to stdout/stderr. Introducing concurrent tasks would mingle the outputs of concurrent tasks with all others, resulting in potentially confusing output. Future work might include redirecting these streams elsewhere (e.g. logs) to resolve this problem.
Services
14 proposes using
EngineState::ctrlc
to interrupt tasks, which would cause all tasks (including concurrent tasks) to terminate. For the purposes of running multiple concurrent services, this would cause all services to be terminated (and not all to necessarily be restarted), which is not ideal.To solve this, a
--service
flag could be added to tasks which implies that it is concurrent and should maintain a separatectrlc
state.