Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: log stderr from daemon #270

Merged
merged 1 commit into from
Jun 20, 2018
Merged

feat: log stderr from daemon #270

merged 1 commit into from
Jun 20, 2018

Conversation

achingbrain
Copy link
Member

  • Renames handlers to stderr and stdout to better reflect what they do.
  • Hooks up stderr handler to data event of daemon's stderr to log data emitted.
  • Uses the callback to handle process errors instead of an extra error handler.
  • Specify stderr and stdout handlers in the method options instead of in a separate argument.
  • No longer buffers all command output automatically as it can lead to out of memory errors on long running processes, instead the calling code can choose to receive stdout/stderr or not.
  • Does not treat any data emitted on stderr as a reason to judge a process as failed when no stderr handler is passed

@ghost ghost assigned achingbrain Jun 19, 2018
@ghost ghost added the status/in-progress In progress label Jun 19, 2018
Renames process handlers to stderr and stdout to better
capture what they do.

Hooks up stderr handler to data event of daemon's stderr to
log data emitted.

Uses the callback to handle errors instead of an extra error
handler.

Specify stderr and stdout handlers in the method options instead
of in a separate argument.

No longer buffers all command output automatically as it can lead
to out of memory errors on long running processes.
@@ -81,8 +113,7 @@ describe('exec', () => {
const args = hang.concat(tok)

const p = exec(args[0], args.slice(1), {}, (err) => {
// `tail -f /dev/null somerandom` errors out
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is correct - on Mac OS at least it complains that somerandom doesn't exist but then continues running tailing /dev/null and doesn't error out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@achingbrain I didn't understand this part.

As far as I understood, on my Mac OS it seems ok, as well as in the CI for macos.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says the command 'errors out', which I took to mean it exits with a non-zero error code. When I run it, it prints out a message that somerandom doesn't exist but continues running.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, tail -f outputs appended data as a file grows. In this case, the file does not exist, but the process still hanging.

I tried to add some data to the file, which I tried to tail and nothing happened as the file does not exist when the command was executed.

This way, I think we can remove the comment as you did!

@achingbrain
Copy link
Member Author

This also fixes #234

achingbrain added a commit to ipfs/js-ipfs that referenced this pull request Jun 20, 2018
Sets up Hapi's debug logging when DEBUG env var is present.

This will enable developers to see what is happening inside
the daemon when ipfs/js-ipfsd-ctl#270 is merged instead of just
getting error messages like 'Please retrace your steps'.

It lets you do this sort of thing:

```
$ DEBUG=ipfsd-ctl:daemon:* npm test
```

...and see Hapi's request/server logs in the output.
Copy link
Member

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job @achingbrain !

I really wanted this change to be made here as well.

@achingbrain
Copy link
Member Author

Is this ok to merge? There's a slight drop in coverage but the tests I've added are skipped during the coverage run so I'm not really sure what I can do about that.

@vasco-santos vasco-santos merged commit c4a175c into master Jun 20, 2018
@ghost ghost removed the status/in-progress In progress label Jun 20, 2018
@vasco-santos vasco-santos deleted the log-stderr-from-daemon branch June 20, 2018 13:59
alanshaw pushed a commit to ipfs/js-ipfs that referenced this pull request Jun 21, 2018
Sets up Hapi's debug logging when DEBUG env var is present.

This will enable developers to see what is happening inside
the daemon when ipfs/js-ipfsd-ctl#270 is merged instead of just
getting error messages like 'Please retrace your steps'.

It lets you do this sort of thing:

```
$ DEBUG=ipfsd-ctl:daemon:* npm test
```

...and see Hapi's request/server logs in the output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants