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

Log exception when dogstatsd server fails to start. Fixes #480 #519

Merged
merged 2 commits into from
May 30, 2013

Conversation

elijahandrews
Copy link
Contributor

Fixes #480.

@@ -221,6 +221,8 @@ def run(self):
self.reporter.start()
try:
self.server.start()
except Exception:
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't work in python 2.4 (which we support for the agent), you'll need to do a nested dealie of

try:
    try:
        ...
    except Exception:
        ...
finally:
   ...

Also, you probably want to reraise the exception, otherwise dogstatsd will exit with a 0 exit code instead of a 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, thanks for pointing that out. Didn't realized that try blocks were exclusively either except or finally blocks before 2.5.

Also, wouldn't we want dogstatsd to exit with an exit code of 1 if it can't start the server, so supervisor can identify that it didn't start correctly? Or are you thinking we try to recover from an Address already in use error by starting the server on a different port.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just realized I misread the second part of your comment. Forget the second part of my comment above :)

Copy link
Contributor

Choose a reason for hiding this comment

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

We do want it to exit with 1. With your new except clause though, you're catching the exception so the code will exit normally as if nothing happened. You'd want to add a raise after your log statement so that the exception bubbles up to the top level and causes an exit 1.

@clutchski
Copy link
Contributor

looks good.

elijahandrews added a commit that referenced this pull request May 30, 2013
Log exception when dogstatsd server fails to start. Fixes #480
@elijahandrews elijahandrews merged commit db3cd73 into master May 30, 2013
@elijahandrews elijahandrews deleted the 480-log-dostatsd-port-error branch May 30, 2013 19:17
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.

If already running statsd on the default port, agent fails with no error
3 participants