Skip to content
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

Using "single-instance": false to avoid problems #62

Open
weggesser opened this issue Dec 2, 2014 · 11 comments
Open

Using "single-instance": false to avoid problems #62

weggesser opened this issue Dec 2, 2014 · 11 comments

Comments

@weggesser
Copy link

First - thanks for your effort! While integrationg your module I had an issue which appeared sometimes - the downloaded and extracted app was not launched. I guess it's because by default node-webkit apps are single-instance only and the downloaded app was launched at a time the old app was not completely shut down. Perhaps you could mention that somewhere in the readme? This issue can be avoided with

"single-instance" : false

setting in the app's packeage json.

@edjafarov
Copy link
Collaborator

wow, nice hint! didn't know - definitely should go in readme.
@adam-lynch you might like it - it should make running apps more stable.

@adam-lynch
Copy link
Collaborator

Yeah, this makes sense and I didn't think of it but this then allows users to open your app multiple times, any time :/

@adam-lynch
Copy link
Collaborator

This then means though that there's more of a chance that the original app is still open when the temporary app is open which deletes the files where the original app exists, which will fail if the original app is still open. But we do have code in there that retries that deletion, right @edjafarov?

@majodev
Copy link

majodev commented Dec 2, 2014

Tried that just now, works way more consistent now.

Just an idea: To keep apps restricted to run in a single instance only, one might want to add this flag to the package.json of a newly downloaded + unpacked release and remove it after the first startup of the upgraded app.

@adam-lynch
Copy link
Collaborator

remove it after the first startup of the upgraded app.

How?

On Tue, 2 Dec 2014 12:31 Mario Ranftl notifications@github.com wrote:

Tried that just now, works way more consistent now.

Just an idea: To keep apps restricted to run in a single instance only,
one might want to add this flag to the package.json of a newly downloaded

  • unpacked release and remove it after the first startup of the upgraded
    app.


Reply to this email directly or view it on GitHub
#62 (comment)
.

@majodev
Copy link

majodev commented Dec 2, 2014

@adam-lynch example procedure after update first start:

var pkg = require('./package.json');
var fs = require('fs');

if (pkg["single-instance"] === false) {
  pkg["single-instance"] = true;

  fs.writeFile('./package.json', JSON.stringify(pkg), function(err) {
    if (err) return console.log(err);
  });
}

Works on bundled (via node-webkit-builder) 32bit mac app, all other platforms untested

@adam-lynch
Copy link
Collaborator

@majodev ah cool, but the original app won't have single-instance set to true so then.

@edjafarov
Copy link
Collaborator

But we do have code in there that retries that deletion, right @edjafarov?

it is for windows only, we might need to add retries for other OSes
https://github.com/edjafarov/node-webkit-updater/blob/master/app/updater.js#L359

@adam-lynch adam-lynch changed the title Problem Starting App in Temp Using "single-instance": false to avoid problems Dec 2, 2014
@majodev
Copy link

majodev commented Dec 2, 2014

@adam-lynch Well it's really just an hack-y idea, I'm really not sure if this "trick" will work consistently across all platforms, so don't use it in production.

It would be perfect if node-webkit provides a way to toggle the single-instance behavior during runtime (I filed an issue...)

@rodolfoag
Copy link

How about using a different package.name for each version, for instance "name": "app-v1.0.0" for old version and "app-v1.0.1" for the new one. This way nw won't interfere since it's use package.name to handle single-instance. Would you consider it a bad practice? Thx.

@adam-lynch
Copy link
Collaborator

Interesting @rodolfoag. I wouldn't have a new version for the each new version (that might have some side-effects depending on OS) but maybe the middle step of the updating process the name could have "-updating" on the end, but I don't know how that could even be done for just the middle step without having to download two versions of the new app. Also if we did this and apps could run alongside each other, would it help us that much? Because on Windows the first app will have to be dead by the time the next step tries to delete it / overwrite it. We might run into more problems with this, maybe this constraint makes it safer for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants