Closed jimallman closed 6 years ago
Just in case the above discussion is lost or just too confusing, here's the neo4j issue that pinpoints the problem with lsof >= 4.87
The patch consists of replacing
newpid=$(lsof -i :$NEO4J_SERVER_PORT -F T -Ts | grep -i "TST=LISTEN" -B1 | head -n1)
with
newpid=$(lsof -i :$NEO4J_SERVER_PORT -F T -Ts | grep "p")
Also, the second line appears to work with earlier versions of lsof as well.
Also, the second line appears to work with earlier versions of lsof as well.
Yes, but note that this can return multiple lines (process ids), which seems problematic:
$ sudo lsof -i :7478 -F T -Ts | grep "p"
p1381
p2633
p2634
I gather the one we're interested in is listed closest to TST=LISTEN
in the full output:
$ sudo lsof -i :7478 -F T -Ts
p1381
TST=LISTEN
p2633
TST=CLOSE_WAIT
p2634
TST=CLOSE_WAIT
Oh, I see.
I think this captures the sense of what we're looking for:
$ sudo lsof -i :7478 -F T -Ts | grep "TST=LISTEN" -B4 | grep "^p" | tail -n1
p1381
In other words:
This should handle changes in order, multiple TST lines, etc.
EDIT TO ADD: So the patched line might look like so:
newpid=$(lsof -i :$NEO4J_SERVER_PORT -F T -Ts | grep "TST=LISTEN" -B4 | grep "^p" | tail -n1)
closing because of "won't fix"
See this Gitter discussion for background and links to a bug tracker with the solution.
Short of upgrading Neo4j, or patching its control script in deployment, our temporary workaround is to downgrade
lsof
to an older version that's compatible. This seems reasonable, since we're transitioning away from Neo4j. But it's one more thing to keep track of.