1.4.1 • Published 9 years ago

multiplexer v1.4.1

Weekly downloads
1
License
ISC
Repository
github
Last release
9 years ago

Multiplexer CLI tool

Takes a filename as an argument. It will then treat each line from this file as a command and spawn a process with it. Finally it will multiplex the output of each of those processes, prefixing each line with the PID of that process.

Usage (CLI)

npm install -g multiplexer
echo "\
while [ 1 ] ; do echo beep ; sleep 1 ; done
while [ 1 ] ; do echo boop ; sleep 1 ; done
while [ 1 ] ; do echo baap ; sleep 1 ; done" > example-commands

multiplexer example-commands

Output:

25242 beep
25244 boop
25246 baap
25242 beep
25244 boop
25246 baap
25242 beep
25244 boop
25246 baap

Usage (as a module)

npm install multiplexer
const multiplexer = require('multiplexer')

multiplexer([
  'while [ 1 ] ; do echo beep ; sleep 1 ; done',
  'while [ 1 ] ; do echo beep ; sleep 1 ; done',
  'while [ 1 ] ; do echo beep ; sleep 1 ; done'
])

Instead of a string, each command can be an object with the following fields:

  • cwd ... Set working directory
  • env ... Set of environment key-value pairs
  • uid ... Run as User ID
  • gid ... Run as Group ID
  • detached ... Detach from parent process
  • alias ... Custom log prefix (default: process id)
  • waitFor ... Wait for process to print given string to stdout before spawning next process
1.4.1

9 years ago

1.4.0

9 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago