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

timeout does not work if the probe is a shell script #8

Open
arosh opened this issue Nov 13, 2018 · 0 comments
Open

timeout does not work if the probe is a shell script #8

arosh opened this issue Nov 13, 2018 · 0 comments

Comments

@arosh
Copy link
Member

arosh commented Nov 13, 2018

When we use the following shell script as a probe and example.com does not return a response for a long time, an execution of the probe will not stop in the specified timeout.

#!/bin/sh
printf "GET / HTTP/1.0\r\n\r\n" | nc example.com 80

An example of configuration file for goma is as follows.

[[monitor]]
name = "example"
interval = 1
timeout = 1
  [monitor.probe]
  type = "exec"
  command = "/path/to/probe"
  [[monitor.actions]]
  type = "mail"
  from = "[email protected]"
  fail_to = ["[email protected]"]

The reason for this is as follows.

  1. exec.CommandContext with context.WithTimeout will kill the process of the probe when the specified time has elapsed. However, the process of nc (the child process of the process of the probe) will not be killed since goma does not kill the whole process group.
  2. If nc does not close its stdout, cmd.Output() will wait to copy the nc process's stdout into the buffer.

See: golang/go#18874 (comment)

@takahisa takahisa assigned takahisa and unassigned takahisa Nov 13, 2018
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

No branches or pull requests

2 participants