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

Better port in use information #369

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions prestoadmin/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,15 @@ def is_port_in_use(host):
with settings(hide('warnings', 'stdout'), warn_only=True):
output = run('netstat -ln |grep -E "\<%s\>" |grep LISTEN' % str(portnum))
if output:
_LOGGER.info("Presto server port already in use. Skipping "
"server start...")
error('Server failed to start on %s. Port %s already in use'
% (env.host, str(portnum)))
if 'command not found' in output:
Copy link
Contributor

Choose a reason for hiding this comment

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

if we set -o pipefail in run(str), we should exercise better control... Or, perhaps, netstat should be run as command and grep as Py-level processing. (with set -o pipefail there is this problem with grep that it reports failure when no line matched, so you'd need | { grep ... || true }...)

@kokosing what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. That is much better!

_LOGGER.info("Presto server has no netstat installed. Skipping "
"server start...")
error("Server failed to start on %s. netstat not installed")
else:
_LOGGER.info("Presto server port already in use. Skipping "
"server start...")
error('Server failed to start on %s. Port %s already in use'
% (env.host, str(portnum)))
return output


Expand Down