Skip to content

Commit

Permalink
issues with port crawling, just use 50011 for now
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelPesce committed Jun 28, 2024
1 parent 9383c5b commit 04816af
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 45 deletions.
28 changes: 14 additions & 14 deletions backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@

def getPort():
port = 50011
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
foundOpenPort = False
while not foundOpenPort:
try:
s.bind(("127.0.0.1", port))
_log.info(f"found open port: {port}")
foundOpenPort = True
except socket.error as e:
if e.errno == errno.EADDRINUSE:
_log.info(f"Port {port} is already in use")
else:
_log.error(f"Error while trying to connect to port {port}: {e}")
port += 1
s.close()
# s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# foundOpenPort = False
# while not foundOpenPort:
# try:
# s.bind(("127.0.0.1", port))
# _log.info(f"found open port: {port}")
# foundOpenPort = True
# except socket.error as e:
# if e.errno == errno.EADDRINUSE:
# _log.info(f"Port {port} is already in use")
# else:
# _log.error(f"Error while trying to connect to port {port}: {e}")
# port += 1
# s.close()
return port

if __name__ == '__main__':
Expand Down
62 changes: 31 additions & 31 deletions electron/ui/src/AppContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,38 @@ export const useApp = () => {

export const AppProvider = ({ children }) => {
const [ port, setPort ] = useState(50011);
const [ foundPort, setFoundPort ] = useState(false)
const [ foundPort, setFoundPort ] = useState(true)

useEffect(() => {
/*
search for backend port
*/
fetch('http://localhost:'+port+'/get_project_name', {
method: 'GET',
mode: 'cors',
})
.then(response => {
if (response.status === 200) {
response.json()
.then((data)=>{
if (data === "pareto") {
// console.log("found pareto on port "+ port)
setFoundPort(true)
}
else {
setPort(port + 1)
}
}).catch((err)=>{
setPort(port + 1)
})
}
else {
setPort(port + 1)
}
}).catch((err) => {
setPort(port + 1)
})
}, [port]);
// useEffect(() => {
// /*
// search for backend port
// */
// fetch('http://localhost:'+port+'/get_project_name', {
// method: 'GET',
// mode: 'cors',
// })
// .then(response => {
// if (response.status === 200) {
// response.json()
// .then((data)=>{
// if (data === "pareto") {
// // console.log("found pareto on port "+ port)
// setFoundPort(true)
// }
// else {
// setPort(port + 1)
// }
// }).catch((err)=>{
// setPort(port + 1)
// })
// }
// else {
// setPort(port + 1)
// }
// }).catch((err) => {
// setPort(port + 1)
// })
// }, [port]);


const value = {
Expand Down

0 comments on commit 04816af

Please sign in to comment.