Skip to content

Instantly share code, notes, and snippets.

Last active Aug 4, 2016
What would you like to do?
a better travis_wait (it prints the script output as it comes in, rather than all at the end)
const spawn = require('child_process').spawn;
const command = process.argv[2];
const args = process.argv.slice(3);
const child = spawn(command, args);
console.log(`heartbeat: running command ${command} with args ${args}`);
const heartbeat = setInterval(() => {
}, 1000 * 60);
const timeout = setTimeout(() => {
console.log('heartbeat: child process timed out after 60 min');
}, 1000 * 60 * 60);
child.stdout.on('data', (data) => {
console.log(data.toString().replace(/\r?\n$/, ''));
child.stderr.on('data', (data) => {
console.log(data.toString().replace(/\r?\n$/, ''));
child.on('close', (code) => {
console.log(`heartbeat: child process exited with code ${code}`);

This comment has been minimized.

Copy link
Owner Author

@keeth keeth commented Aug 4, 2016

it expects to be run like node heartbeat.js myscript arg1 arg2

(it expects to find the program to run at argv[2])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment