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

consul not logging on Upstart #182

Closed
jeremyjh opened this issue Nov 13, 2016 · 5 comments · May be fixed by #188
Closed

consul not logging on Upstart #182

jeremyjh opened this issue Nov 13, 2016 · 5 comments · May be fixed by #188

Comments

@jeremyjh
Copy link
Contributor

consul is not logging when using upstart - at least on Ubuntu. /var/log/consul will remain empty.

This is due to a bug introduced in df10349 .

This line is incorrect because &>> is bash syntax, it is not compatible with bin/sh.

  exec su -s /bin/sh -c 'GOMAXPROCS=`nproc` exec "$0" "$@" &>>{{ consul_log_file }}' consul -- /opt/consul/bin/consul agent 

This should resolve the issue:

  exec su -s /bin/sh -c 'GOMAXPROCS=`nproc` exec "$0" "$@" 1>> {{ consul_log_file }} &2>1' consul -- /opt/consul/bin/consul agent 
@jzvelc
Copy link

jzvelc commented Nov 14, 2016

You got closer but an issue with permissions remains (you can't write logs in /var/log as a consul user).
What about something like this?

 exec su -s /bin/sh -c 'GOMAXPROCS=`nproc` exec "$0" "$@"' consul -- /opt/consul/bin/consul agent > {{ consul_log_file }} 2>&1

I have tested this out and it works as expected on debian/ubuntu (with upstart) but I am not sure about rhel/centos.

@jeremyjh
Copy link
Contributor Author

You can.../var/log/consul is touched and chown to consul:consul during
install I believe - that is the owner after install in any case.
The previous code worked the same way in this regard and I've used my
branch for successful deployments already on Ubuntu.

On Monday, November 14, 2016, Jure Žvelc [email protected] wrote:

You got closer but an issue with permissions remains (you can't write logs
in /var/log as a consul user).
What about something like this?

exec su -s /bin/sh -c 'GOMAXPROCS=nproc exec "$0" "$@"' consul -- /opt/consul/bin/consul agent > {{ consul_log_file }} 2>&1

I have tested this out and it works as expected on debian/ubuntu (with
upstart) but I am not sure about rhel/centos.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#182 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAFhjgGYz6t67qGR8woNmbhiaMtdKx1Jks5q-HN7gaJpZM4Kwzhr
.

@jzvelc
Copy link

jzvelc commented Nov 15, 2016

I just checked and I can confirm owner/g is consul:consul so it seems it is something else... Can you check if stopping/restarting upstart service works as expected? If I try to restart it I get stop: Unknown instance:. So the issue is that service doesn't stop and restarting fails due to address already in use error.
Please check following log file: /var/log/upstart/consul.log
With your script I get following entries:
/opt/consul/bin/consul: 1: /opt/consul/bin/consul: cannot create 1: Permission denied

@jzvelc
Copy link

jzvelc commented Nov 15, 2016

What about this:
exec su -s /bin/sh -c 'GOMAXPROCS=nprocexec "$0" "$@" > /var/log/consul 2>&1' consul -- /opt/consul/bin/consul agent

This also works for me.

@jeremyjh
Copy link
Contributor Author

The only difference is it would totally wipe out the log each restart since
you are not appending. We could touch and chown the log before we su to be
sure in case permissions are a problem in some context.

Restarts are a different issue but I don't think it worked under sudo
either.

On Tuesday, November 15, 2016, Jure Žvelc [email protected] wrote:

What about this:
exec su -s /bin/sh -c 'GOMAXPROCS=nprocexec "$0" "$@" > /var/log/consul
2>&1' consul -- /opt/consul/bin/consul agent

This also works for me.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#182 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAFhjpQ_3w4n2MU8fSt9Bavl8hDssbieks5q-WsOgaJpZM4Kwzhr
.

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 a pull request may close this issue.

2 participants