{"action":"created","issue":{"url":"https://api.github.com/repos/atom/electron/issues/3145","labels_url":"https://api.github.com/repos/atom/electron/issues/3145/labels{/name}","comments_url":"https://api.github.com/repos/atom/electron/issues/3145/comments","events_url":"https://api.github.com/repos/atom/electron/issues/3145/events","html_url":"https://github.com/atom/electron/pull/3145","id":112209938,"number":3145,"title":"Implement Single-Instance for Windows / Linux","user":{"login":"paulcbetts","id":1396,"avatar_url":"https://avatars.githubusercontent.com/u/1396?v=3","gravatar_id":"","url":"https://api.github.com/users/paulcbetts","html_url":"https://github.com/paulcbetts","followers_url":"https://api.github.com/users/paulcbetts/followers","following_url":"https://api.github.com/users/paulcbetts/following{/other_user}","gists_url":"https://api.github.com/users/paulcbetts/gists{/gist_id}","starred_url":"https://api.github.com/users/paulcbetts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulcbetts/subscriptions","organizations_url":"https://api.github.com/users/paulcbetts/orgs","repos_url":"https://api.github.com/users/paulcbetts/repos","events_url":"https://api.github.com/users/paulcbetts/events{/privacy}","received_events_url":"https://api.github.com/users/paulcbetts/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-19T19:00:14Z","updated_at":"2015-10-20T01:56:49Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/atom/electron/pulls/3145","html_url":"https://github.com/atom/electron/pull/3145","diff_url":"https://github.com/atom/electron/pull/3145.diff","patch_url":"https://github.com/atom/electron/pull/3145.patch"},"body":"This PR implements a new proposed API on `app` which allows Electron apps on Windows and Linux to be single-instance apps (and receive the command-line parameters from secondary invocations).\r\n\r\n### Proposed API\r\n\r\n```js\r\nimport app from 'app';\r\n\r\nshouldQuit = app.makeSingleInstance((cmdLine) => {\r\n  // TODO: Handle command line from secondary instance\r\n});\r\n\r\nif (shouldQuit) app.quit(0);\r\n```\r\n\r\nWhen apps are invoked as the secondary instance (i.e. an instance is already running), `makeSingleInstance` will send the command-line arguments to the primary instance and exit the app. This means that `makeSingleInstance` should be called as early as possible (i.e. before `ready`), so we'll set it up for that to be possible\r\n\r\n## TODO:\r\n\r\n- [x] Bring the code over from Chrome that implements this\r\n- [x] Make the code compile on Windows\r\n- [x] Make the code compile on Linux\r\n- [x] Wire it up to `app`\r\n- [ ] Fix all the TODOs"},"comment":{"url":"https://api.github.com/repos/atom/electron/issues/comments/149399540","html_url":"https://github.com/atom/electron/pull/3145#issuecomment-149399540","issue_url":"https://api.github.com/repos/atom/electron/issues/3145","id":149399540,"user":{"login":"zcbenz","id":639601,"avatar_url":"https://avatars.githubusercontent.com/u/639601?v=3","gravatar_id":"","url":"https://api.github.com/users/zcbenz","html_url":"https://github.com/zcbenz","followers_url":"https://api.github.com/users/zcbenz/followers","following_url":"https://api.github.com/users/zcbenz/following{/other_user}","gists_url":"https://api.github.com/users/zcbenz/gists{/gist_id}","starred_url":"https://api.github.com/users/zcbenz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zcbenz/subscriptions","organizations_url":"https://api.github.com/users/zcbenz/orgs","repos_url":"https://api.github.com/users/zcbenz/repos","events_url":"https://api.github.com/users/zcbenz/events{/privacy}","received_events_url":"https://api.github.com/users/zcbenz/received_events","type":"User","site_admin":true},"created_at":"2015-10-20T01:56:49Z","updated_at":"2015-10-20T01:56:49Z","body":"Can you move the `process_singleton` stuff to the `chromium_src` dir, and keep the function and namespace names as they are? If we are lucky we only need to change few lines to the original source code, and it will make future maintenance work easier."}}