Skip to content

Commit 7908627

Browse files
committed
Use PID
1 parent b6e4faf commit 7908627

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

bin.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function createServer (storage, opts) {
150150
async function simulator () {
151151
if (argv._.length === 1) throw new Error('Must provide a script for the simulator to run.')
152152
const scriptPath = p.resolve(argv._[1])
153-
const simulatorId = await getUnusedSocket()
153+
const simulatorId = `hyperspace-simulator-${process.pid}`
154154
process.env.HYPERSPACE_SOCKET = simulatorId
155155

156156
const server = createServer(ram, {
@@ -174,18 +174,6 @@ async function simulator () {
174174
console.log('Shutting down simulator...')
175175
server.close().catch(onerror)
176176
}
177-
178-
async function getUnusedSocket () {
179-
const host = `hyperspace-simulator-${(Math.floor(Math.random() * 1e9)).toString(16)}`
180-
const socketPath = getNetworkOptions({ host })
181-
try {
182-
await fs.stat(socketPath)
183-
return getUnusedSocket()
184-
} catch (err) {
185-
if (err.code !== 'ENOENT') throw err
186-
return host
187-
}
188-
}
189177
}
190178

191179
async function getStoragePath () {

0 commit comments

Comments
 (0)