Electron app respawns itself


#1

hello community,

i ran into problems when using “pm2” with a very basic electron app (issue occurs in production version only). Running the app from terminal via electron main.js or drag/dropping the app_folder into the electron_launcher_window works just fine (pm2 starts my process). But once i pack the app for release via electron-packager it keeps reopening itself in a loop after launch (without launching pm2 and my process). I end up with multiple launched apps before i kill them manually. pm2 has been rebuilt against used electron version before packing. Any idea what could be wrong?

main.js: https://gist.github.com/ca333/187a6d8603424b50ca518cccfc82bcf5

the pm2 code part inside createWindow() is confirmed to work:

pm2.connect(function(err) { //start up pm2 god
    if (err) {
      console.error(err);
      process.exit(2);
    }

    var binpath = './path/to/my/binary';
    pm2.start({
    script    : binpath,         
    exec_mode : 'fork',
    cwd: './working_dir/'
    }, function(err, apps) {
       pm2.disconnect();   
       if (err) throw err
    });
});

Calling npm module via exec fails in production
Calling npm module via exec fails in production
#3

With my small experience with Electron, I remember having path problem in Production and changing all my ./xx to __dirname +"/xx".
Perhaps it could help