mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Check whether the socket file exists before connecting.
By removing the socket file when the browser process of Atom quits and checking it's existence before trying to connect it, we can greatly reduce the startup time of the first instance of Atom.
This commit is contained in:
@@ -82,11 +82,15 @@ class AtomApplication
|
||||
process.env['NODE_PATH'] = resourcePaths.join path.delimiter
|
||||
|
||||
sendArgumentsToExistingProcess: (pidToKillWhenClosed, callback) ->
|
||||
if not fs.existsSync(@socketPath)
|
||||
callback(false)
|
||||
return
|
||||
|
||||
client = net.connect {path: @socketPath}, (args...) =>
|
||||
client.write(JSON.stringify({@pathsToOpen, pidToKillWhenClosed}))
|
||||
callback(true)
|
||||
|
||||
client.on 'error', (args...) -> callback(false)
|
||||
client.on 'error', (error) -> console.log(error); callback(false)
|
||||
|
||||
listenForArgumentsFromNewProcess: ->
|
||||
fs.unlinkSync @socketPath if fs.existsSync(@socketPath)
|
||||
@@ -155,6 +159,10 @@ class AtomApplication
|
||||
app.on 'window-all-closed', ->
|
||||
app.quit()
|
||||
|
||||
# Clean the socket file when quit normally.
|
||||
app.on 'will-quit', =>
|
||||
fs.unlinkSync @socketPath if fs.existsSync(@socketPath)
|
||||
|
||||
ipc.on 'close-without-confirm', (processId, routingId) ->
|
||||
window = BrowserWindow.fromProcessIdAndRoutingId processId, routingId
|
||||
window.removeAllListeners 'close'
|
||||
|
||||
Reference in New Issue
Block a user