nwutils / nw-updater

Update NW.js applications.
MIT License
474 stars 91 forks source link

Make updater a separate app/process. #1

Open edjafarov opened 10 years ago

edjafarov commented 10 years ago

It might make sense to put all logic inside separate process that will work as a service and will download and update the version of the app. Maybe something like network installer might be a great idea. Updater will be able to download initial version of app and install it.

node_webkit_updater process will be a detached process that will run kind of local server any node-webkit app will be able to call this server's API give current manifest, subscribe for updates, give current app folder if there is node_webkit_updater app will subscribe for existing otherwise it will spawn new one if there is a new version of app available node-webkit-updater will download it in tmp folder and ping original app for approve. original app should approve update and teardown itself node-webkit-updater will try to copy the app to original folder and run app (we need to think out what error cases could be)

adam-lynch commented 10 years ago

We considered a separate updater app but we were worried about the size of our end app if this is bundled with it (because of all the node-webkit boilerplate needed to make an updater app).

edjafarov commented 10 years ago

That makes sense. Need to think about it.

edjafarov commented 10 years ago

rogerwang/node-webkit#213 when fixed will allow to run js files in webworker. I guess that would also allow to run updater as background app. So the app, when running will fork the updater in separate process. The app should be able to hook on updater. Updater will handle everything.

adam-lynch commented 10 years ago

@edjafarov rogerwang/node-webkit#213 seems to be fixed. What do you think now?

matthew-dean commented 9 years ago

@adam-lynch I've used child processes quite a bit for my NW.js app. They work great. I don't think you would need a separate updater app (nor does it seem wise, since it could create a stack of add-on dependency problems, where different apps actually need different versions of node-webkit-updater). You should be able to npm install node-webkit-updater and do a require() as you would normally, and spawn child processes as needed.

I've been thinking about it, though... Child processes are not free (in terms of memory / CPU), meaning you should only spawn one if there's an actual update to download. But... if all that's happening is an http download, is that even blocking the main thread anyway? Or is that handled by a system call that just sends back an event to node when it's done (which would make a child process irrelevant)? I actually don't know the answer to that.