'Restart electron app in new detached process

I have an electron (v17) application running in a linux (v20.04) environment as an AppImage.

What I want to achieve

The application should be able to shut itself down completely and re-open in a new and independant context (no child process).

What I have tried

First thing was to try the suggested method from the docs. Unfortunetly in my context that does not work at all (app closes but does not reopen as this issue confirms).
I noticed that the AppImage is exectuted from a temporaray directory (/tmp/.mount_MyAppSomeHash whereas the original app is located in ~/MyApp/Name.AppImmage)
So I also tried to pass relaunch options with the execution path specified as described here. Again with no luck.
What did work though, was to run the original AppImage via execFile from the child_process module...

The problem

Using the execFile like below will spawn new processes and the original ones seem to persist. Also another temporary folder is created alongside the original. So it piles up.

execFile(process.env.APPIMAGE, options.args)
app.quit()

Ideas

Could a long-running master process that runs the AppImage as a child be a viable option? How course theese processes would have to communicate with each other on when to terminate and spawn a new one. Is the node child_process module the right option then? Or should I lean into a shell script of sorts?\

I'm not really sure how to tackle this, so I'd be glad for any input!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source