New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add app.relaunch API #5837

Merged
merged 16 commits into from Jun 3, 2016

Conversation

Projects
None yet
3 participants
@zcbenz
Contributor

zcbenz commented Jun 2, 2016

### `app.relaunch([options])`

* `options` Object (optional)
  * `args` Array (optional)
  * `execPath` String (optional)

Relaunches the app when current instance exits.

By default the new instance will use the same working directory and command line
arguments with current instance. When `args` is specified, the `args` will be
passed as command line arguments instead. When `execPath` is specified, the
`execPath` will be executed for relaunch instead of current app.

Note that this method does not quit the app when executed, you have to call
`app.quit` or `app.exit` after calling `app.relaunch` to make the app restart.

When `app.relaunch` is called for multiple times, multiple instances will be
started after current instance exited.

Close #539.

@zcbenz zcbenz merged commit 4ec064d into master Jun 3, 2016

9 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
electron-linux-arm Build #3360436 succeeded in 46s
Details
electron-linux-ia32 Build #3360437 succeeded in 40s
Details
electron-linux-x64 Build #3360438 succeeded in 120s
Details
electron-mas-x64 Build #1390 succeeded in 5 min 12 sec
Details
electron-osx-x64 Build #1392 succeeded in 6 min 20 sec
Details
electron-win-ia32 Build #394 succeeded in 6 min 9 sec
Details
electron-win-x64 Build #389 succeeded in 6 min 16 sec
Details

@zcbenz zcbenz deleted the restart branch Jun 3, 2016

@kaepora kaepora referenced this pull request Jun 9, 2016

Open

Improved auto-update #66

@brumm brumm referenced this pull request Jul 2, 2016

Merged

replace OSX window title bar with custom title-bar #11790

1 of 1 task complete

@MarshallOfSound MarshallOfSound referenced this pull request Sep 2, 2016

Closed

app.restart() #539

@ghost

This comment has been minimized.

ghost commented Sep 25, 2017

I believe this API doesn't work on mas builds (due to my own testing) but it doesn't say that in the docs. @zcbenz can you confirm that it doesn't work in mas builds? If so I'm happy to make a PR tp update the docs 😄

@zcbenz

This comment has been minimized.

Contributor

zcbenz commented Sep 26, 2017

@callodacity Hmm it seems to work on my side.

Steps:

  1. Download mas build
  2. Open it and run require('electron').remote.app.relaunch() in devtools
  3. Close window
  4. Electron restarts
@ghost

This comment has been minimized.

ghost commented Sep 26, 2017

@zcbenz Yes that works - but I should have given some more information. If you sign the build then it won't relaunch.

Steps:

  1. Download mas build
  2. Sign Electron
  3. Open it and run require('electron').remote.app.relaunch() in devtools
  4. Quit application
  5. Electron quits and doesn't relaunch
@TheMaverickProgrammer

This comment has been minimized.

TheMaverickProgrammer commented Nov 18, 2017

This isn't working for me. Electron starts after quitting my application telling me to drag my program into it. This isn't what I expected.

@MarshallOfSound

This comment has been minimized.

Member

MarshallOfSound commented Nov 18, 2017

@TheMaverickProgrammer This is because you launched your application using the electron binary and a path to your app (electron .). When you use this API in a packaged app it will work fine, when launching from the electron binary you need to ensure you provide the path to your app as an argument

@TheMaverickProgrammer

This comment has been minimized.

TheMaverickProgrammer commented Nov 18, 2017

I resolved the issue by passing in the same process arguments as the initial window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment