Force logs command to exit when not in --tail mode. Fix #14.

PubNub keeps the process alive after a history query for some reason, so
trying to print the logs history like:

	$ resin logs <uuid>

Will result in the logs being printed correctly, but the process waiting
infinitely without ending.

The workaround consists in forcing `process.exit` to exit the process
with an error code zero.

Caveats:

- This workaround prevents this command to be used programatically.

Issue: https://github.com/resin-io/resin-cli/issues/14
This commit is contained in:
Juan Cruz Viotti 2015-08-13 15:08:16 -04:00
parent 2e8ec3ac64
commit 69566f7fc3
2 changed files with 9 additions and 2 deletions

View File

@ -24,7 +24,9 @@
return console.log(line.message);
});
if (!options.tail) {
return promise.nodeify(done);
return promise["catch"](done)["finally"](function() {
return process.exit(0);
});
}
return promise.then(function() {
return resin.logs.subscribe(params.uuid).then(function(logs) {

View File

@ -34,7 +34,12 @@ module.exports =
console.log(line.message)
if not options.tail
return promise.nodeify(done)
# PubNub keeps the process alive after a history query.
# Until this is fixed, we force the process to exit.
# This of course prevents this command to be used programatically
return promise.catch(done).finally ->
process.exit(0)
promise.then ->
resin.logs.subscribe(params.uuid).then (logs) ->