Skip to content

Commit

Permalink
Apply port handling improvements to happ store install code too
Browse files Browse the repository at this point in the history
  • Loading branch information
lucksus committed Jan 22, 2020
1 parent 3ea49c4 commit cfc1f2d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions views/install_bundle_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ ipcRenderer.on('conductor-call-set', () => {
installed_instances: [],
installed_dnas: [],
installed_bridges: [],
used_ports: [],
happ_index: [],
selected_happ: undefined,
expanded_happs: {},
Expand Down Expand Up @@ -509,10 +508,12 @@ ipcRenderer.on('conductor-call-set', () => {
console.log('Bridge added')
}

const nextMinPort = () => {
if(app.used_ports.length > 0) {
app.used_ports.sort()
return app.used_ports[app.used_ports.length -1] + 1
const nextMinPort = async () => {
const interfaces = await call('admin/interface/list')()
if (Array.isArray(interfaces) && interfaces.length > 0) {
const ports = []
interfaces.forEach(i => ports.push(i.driver.port))
return Math.max(...ports) + 1
} else {
return 10000
}
Expand All @@ -531,8 +532,8 @@ ipcRenderer.on('conductor-call-set', () => {
console.log(`Creating interface for ${ui.name}`)
let id = `${ui.name}-interface`
let type = 'websocket'
let port = await getPort({port: getPort.makeRange(nextMinPort(), 31000)})
app.used_ports.push(port)
let minPort = await nextMinPort()
let port = await getPort({port: getPort.makeRange(minPort, 31000)})
await call('admin/interface/add')({id,admin,type,port})

for(let ref of ui.instance_references) {
Expand Down

1 comment on commit cfc1f2d

@kristoferlund
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Please sign in to comment.