Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

uchiwa outputs "Uchiwa is now listening on" before attempting to open port #352

Closed
LeslieCarr opened this issue Jul 2, 2015 · 2 comments

Comments

@LeslieCarr
Copy link

Background - I was attempting to run uchiwa on port 80 and it seemed to silently exit, however uchiwa would successfully run as root. I would see {"Date":"2015-07-02T17:55:22.798964641Z","Level":"info","Src":{"Func":"github.com/sensu/uchiwa/uchiwa.(*Uchiwa).WebServer","Line":274},"Output":"Uchiwa is now listening on 0.0.0.0:80"} in the logs, however the service would immediately exit.

Interesting part of the strace is below --

write(1, "{\"Date\":\"2015-07-02T18:05:08.028"..., 188{"Date":"2015-07-02T18:05:08.028877731Z","Level":"info","Src":{"Func":"github.com/sensu/uchiwa/uchiwa/config.Load","Line":73},"Output":"Loading configuration file /etc/sensu/uchiwa.json"}
) = 188
open("/etc/sensu/uchiwa.json", O_RDONLY|O_CLOEXEC) = 3
clock_gettime(CLOCK_MONOTONIC, {153818, 237067041}) = 0
clock_gettime(CLOCK_MONOTONIC, {153818, 237104019}) = 0
read(3, "{\n\"sensu\": [\n    {\n      \"name\":"..., 512) = 336
clock_gettime(CLOCK_MONOTONIC, {153818, 237190242}) = 0
clock_gettime(CLOCK_MONOTONIC, {153818, 237280045}) = 0
clock_gettime(CLOCK_MONOTONIC, {153818, 237369835}) = 0
clock_gettime(CLOCK_REALTIME, {1435860308, 29873923}) = 0
write(1, "{\"Date\":\"2015-07-02T18:05:08.029"..., 185{"Date":"2015-07-02T18:05:08.029873923Z","Level":"info","Src":{"Func":"github.com/sensu/uchiwa/uchiwa.(*Uchiwa).WebServer","Line":274},"Output":"Uchiwa is now listening on 0.0.0.0:80"}
) = 185
socket(PF_INET6, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 4
setsockopt(4, SOL_IPV6, IPV6_V6ONLY, [0], 4) = 0
setsockopt(4, SOL_SOCKET, SO_BROADCAST, [1], 4) = 0
setsockopt(4, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(4, {sa_family=AF_INET6, sin6_port=htons(80), inet_pton(AF_INET6, "::", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = -1 EACCES (Permission denied)
close(4)                                = 0
exit_group(0)                           = ?
+++ exited with 0 +++

You can see that the message that uchiwa is listening on a port comes before the attempt to open the port. Can you please move the message after the port is opened so that this is easier to debug.

@palourde
Copy link
Contributor

palourde commented Jul 6, 2015

Hi @LeslieCarr,

Unfortunately it isn't possible to add anything after the http.ListenAndServe function. However, we could wrap it with logger.Fatal like this so if you attempt to start Uchiwa on a privileged port with an unprivileged user, the following error would be thrown:

{"Date":"2015-07-06T13:53:35.276351058-04:00","Level":"info","Src":{"Func":"github.com/sensu/uchiwa/uchiwa/config.Load","Line":75},"Output":"Loading configuration file ./config.json"}
{"Date":"2015-07-06T13:53:35.276992056-04:00","Level":"info","Src":{"Func":"github.com/sensu/uchiwa/uchiwa.(*Uchiwa).WebServer","Line":286},"Output":"Uchiwa is now listening on 0.0.0.0:80"}
{"Date":"2015-07-06T13:53:35.277079942-04:00","Level":"fatal","Src":{"Func":"github.com/sensu/uchiwa/uchiwa.(*Uchiwa).WebServer","Line":288},"Output":"listen tcp 0.0.0.0:80: bind: permission denied"}

Do you think it would be an appropriate solution?

@LeslieCarr
Copy link
Author

That would definitely help in troubleshooting!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants