child process closing immediately
Arro opened this issue · comments
Phil commented
If you're not familiar with icecast, it's a multimedia server.
When I run icecast -c ./icecast/icecast.xml
in the terminal, it starts an icecast server, which stays alive.
So I want to run that command alongside my node.js process, every time I run gulp
.
I added the following to my gulpfile.
import exec from 'gulp-exec'
...
const icecastDir = path.resolve(`${__dirname}/icecast/`)
...
gulp.task(`icecast`, () => {
return exec(`/usr/local/bin/icecast -c ${icecastDir}/icecast.xml`)
.on(`data`, () => {
console.log(`data`)
})
.on(`error`, () => {
console.log(`error`)
})
.on(`end`, () => {
console.log(`end`)
})
.on(`close`, () => {
console.log(`error`)
})
.on(`readable`, () => {
console.log(`readable`)
})
})
When I run the command gulp icecast
in my terminal, gulp says Starting 'icecast'...
and then immediately terminates. None of the callbacks fire. I'd really like it to stay alive until I cmd-c the gulp process.
Rob Richardson commented
You're not piping any filenames into it. In this case, don't use gulp-exec
and use child_process#exec
directly.
Phil commented
Thx for this response, by the way. Closing.