Skip to content
This repository has been archived by the owner on Sep 30, 2019. It is now read-only.

Bug with getting PID by port #151

Open
Frikitrok opened this issue Jun 25, 2019 · 9 comments
Open

Bug with getting PID by port #151

Frikitrok opened this issue Jun 25, 2019 · 9 comments

Comments

@Frikitrok
Copy link

Added more debug and what i can see that for some reason portOnPID const is empty. I tried another modules but still get this empty PID list which brake validation of port binding.
Not sure where this comes from, maybe because of my centos distribution

Emulator has started but need to verify socket
62224
{ all: [], tcp: [], udp: [] }

@cbaron
Copy link
Contributor

cbaron commented Jun 25, 2019

@Frikitrok -- sorry to learn you're having issues. You're welcome to put up a PR which handles the centos case. I don't have time to take a deep dive immediately, but let me know how I can assist.

@lightsofapollo
Copy link
Contributor

I wonder if there is a timeout 🤔 happening before dynamodb emulator starts.

@Frikitrok
Copy link
Author

what timeout?
i can add that after i removed port binding validation, everything works well
still not sure is there a problem with port-pid module, or maybe permission issue

@lightsofapollo
Copy link
Contributor

Ah I was thinking about the dynamodb output but that would show up in the logs hrrm. I will review port-pid and see if I can provide insight. Some of that may indeed be specific to the distro.

@lightsofapollo
Copy link
Contributor

Seems likely that the format on your machine is different than the expected format coming from lsof which I believe is invoked directly here https://github.com/radiovisual/port-pid/blob/master/index.js (directly here https://github.com/radiovisual/netstats/blob/master/index.js#L12 in sub dep). We can potentially use another module here that is more resilient to different distros/os ?

@Frikitrok
Copy link
Author

Frikitrok commented Jun 26, 2019

Wow, that where the problem, on my cenots os and centos 7 docker container were no 'lsof' package at all. Installed it and everything went to normal.

I tried to use find-process and pid-from-port npm packages but looks like they use one of these 'netstat' 'lsof' 'fuser' staff. So i think there no common way for all distro to make this work.

I think for now you could add to prerequisites to install 'lsof' package to readme. and add correct debug if return is empty, smthing like 'can not verify port, install lsof and try again'

@Frikitrok
Copy link
Author

Or remove this validation, shouldn't nodejs throw error if something already bind on port?

@Frikitrok
Copy link
Author

instead of using validation, maybe better to add catch on java spawn?
proc.on('error', (err) => {
console.log('Failed to start simulator.');
throw new Error(${givenOptions.port} is bound and unavailable);
});

@lightsofapollo
Copy link
Contributor

I will take a look to see if there is something I can do quickly here but your best bet (i.e. fastest) is to contribute a fix that works on your machine. happy to continue to support here.

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

3 participants