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

[Improvement] Add port checks for MySQL and Postgres #22

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

justinmclean
Copy link
Member

Add scripts to check if ports are in use and that means the user is likely running MySQl or Posgres locally. I assume for this scripts to run new MySQL and Postgres docker images will need to be made. I tested the scripts manually and they detected if the port was in use.

@justinmclean justinmclean changed the title [Improvement] Add port checks for MySQl and Postgres [Improvement] Add port checks for MySQL and Postgres Jan 16, 2024
@qqqttt123
Copy link
Contributor

Think twice. The shell shouldn't take effect. The shell of init.sh should be executed in the Docker image container. The ports are available all the time.

@justinmclean
Copy link
Member Author

justinmclean commented Jan 17, 2024

Ah, yes, you are right. This doesn't fix the issue; I'll pull the script out and place them in the launch script.

echo "Checking if MySQL is runing"
if lsof -Pi :3306 -sTCP:LISTEN -t >/dev/null ; then
echo "MySQL may allready be running on port 3306. Please shut down MySQL before launching the playground."
exit
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to exit with code -1, too?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so other existing exit in the script doesn't exit with -1

@qqqttt123
Copy link
Contributor

Is the scrip ok for both mac and linux?

@justinmclean
Copy link
Member Author

Is the script ok for both Mac and Linux?

Yep see https://manpages.ubuntu.com/manpages/bionic/en/man8/lsof.8.html

echo "Checking if Postgres is runing"
if lsof -Pi :5432 -sTCP:LISTEN -t >/dev/null ; then
echo "Postgres may allready be running on port 5432. Please shut down Postgres before launching the playground."
exit -1
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we exit with code -1 here?

@shaofengshi
Copy link
Contributor

This is something similar as #60, I propose to solve that by chaning to an less possible conflict port in local, which is common used in docker deployments.

@shaofengshi
Copy link
Contributor

Hi Justin, I have changed the playground to use non-default ports to avoid such conflicts, see: fd68dd2

So I think this PR is not needed; If user still got conflict (the possibility is very low), he can modify the yaml.

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.

3 participants