-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
electron.app.relaunch doesn't work inside AppImage #1727
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Unstale please! |
For what it's worth, execFile (From child_process) on the AppImage should cause it to relaunch. |
hi @camhart have you got an example of what your doing here please? Im getting the same issue. |
@peteringram0 the code below will launch the new AppImage--just be sure to exit
Keep in mind AppImage's execute from a temp directory, so I don't think you can use __filename, which is why I've hardcoded the execPath and that feature simply doesn't work if it's moved from that location. If someone knows how to get the actual AppImage path when executing from a temp directory I'd love to hear how. |
After disconnecting the client from the remote Cozy, we restart the application so the user can go through the on-boarding process again on a clean slate. This was done by programing a client stop (via `setTimeout`) before preparing and spawning a new client. However, if the new client is spawned fast enough, the old client could not be stopped already. To avoid this situation with the potential for unpredictable behavior, we switched to the restart solution provided by electron. It consists in preparing the arguments of a new client and telling electron the next time the app is exited, it should be restarted with the given arguments. This seems to have fixed the disconnection issue we had on Windows. The only caveat is this solution does not work with applications packaged as AppImage like we do on Linux (see electron-userland/electron-builder#1727). As a result, we'll keep the old solution on Linux until this is resolved.
After disconnecting the client from the remote Cozy, we restart the application so the user can go through the on-boarding process again on a clean slate. This was done by programing a client stop (via `setTimeout`) before preparing and spawning a new client. However, if the new client is spawned fast enough, the old client could not be stopped already. To avoid this situation with the potential for unpredictable behavior, we switched to the restart solution provided by electron. It consists in preparing the arguments of a new client and telling electron the next time the app is exited, it should be restarted with the given arguments. This seems to have fixed the disconnection issue we had on Windows. The only caveat is this solution does not work with applications packaged as AppImage like we do on Linux (see electron-userland/electron-builder#1727). As a result, we'll keep the old solution on Linux until this is resolved.
It's my workaround: /* ... args ... */
const {app} = require('electron');
const options = {args};
if (process.env.APPIMAGE) {
options.execPath = process.env.APPIMAGE;
options.args.unshift('--appimage-extract-and-run');
}
app.relaunch(options);
app.exit(0); |
After applying the workaround that @Skywalker13 mentioned the app did restart but I wasn't able to execute any const options: RelaunchOptions = {
args: process.argv.slice(1).concat(['--relaunch']),
execPath: process.execPath
};
// Fix for .AppImage
if (app.isPackaged && process.env.APPIMAGE) {
execFile(process.env.APPIMAGE, options.args);
app.quit();
return;
}
app.relaunch(options);
app.quit(); Hopefully it will save someone some time :) |
This might be related to electron/electron#34808 ? |
I need to modify @madmurl0c 's workaround for it to work with both AppImage version and direct (debug) version. Here it is:
|
@peteringram0 the code below will launch the new AppImage--just be sure to exit //I'm using the following to quit (upon upgrade)--I haven't tested whether just app.quit() works in place of this but I would think so const execPath = path.join(getHomeFolder(), 'SomeApp.AppImage') It's my workaround: /* ... args ... */ this is work for me. i have relaunch app in specific time interval. i have ubuntu 22.04 |
Calling
electron.app.relaunch()
from within an AppImage does not properly relaunch the application uponelectron.app.quit()
. This is true both for the no-argument form ofrelaunch()
, as well as if anexecPath
is provided, even if theexecPath
is outside theAppImage
e.g.:
Interestingly, the
relaunch()
method does work correctly if the application binary within the mounted AppImage is started directly. (e.g., run the AppImage once to cause the/tmp/.mount*
to happen, and then go into that mountpoint while the first copy is still running and execute the electron binary directly. This second directly-executed copy is able to correctly relaunch, but the first copy is not)The text was updated successfully, but these errors were encountered: