Api suggestion: API.App.restart
Support for restarting the application. It should restart with the same invocation flags it was started with in the first place. This would be great when it comes to auto-updating.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Can't you just refresh the page?
document.location.reload(true)
Sure, you could do that. But what if the application holds an exclusive lock on a file you are going to update? What if you want to replace the chromium binary blob itself?
+1
I'll implement App.restart() after #64 is done.
+1
Any thoughts / priority on this restart API? Would be great.
+1 for a clean restart function
Any updates on this feature?
+1 for this!
+1 It would be nice to auto update applications.
This feature would be helpful when doing updates, as you can provide the user with a button to restart the application instead of asking them to close and reopen.
It is a real nuisance to do this with shell scripts. Since after you've spawned the script you'll have to wait until the app process terminates. And it is hard to do right path parameter sanitising (e.g. spaces). Not to mention Unicode text which I believe is not supported on Windows, or is it? The Windows shell script:
@echo off
rem usage: relaunch_app.bat <seconds to wait> <executable to launch> <arguments>
rem i.e. $>relaunch_app.bat 5 "C:\Program Files\Jujusoft\JujuEdit\JujuEdit.exe" "C:\Windows\system.ini"
echo Restarting in %1 seconds...
title Waiting
rem Windows 7
@timeout /t %1 /nobreak >nul 2>&1
rem Windows XP
if errorlevel 1 ping 192.0.2.2 -n 1 -w %1000 > nul
rem # launch the executable via start command
start /B "" %2 %3 %4
And on Mac:
echo "Please wait for ${1} seconds.."
sleep $1
open -n -a "${2}" --args $3
In your node-webkit app:
child_process.spawn(path.join(process.cwd(), "relaunch_app.bat")
, [waitSecs.toString()
, (process.platform == "darwin") ? process.execPath.match(/^([^\0]+?\.app)\//)[1]
: process.execPath
]
, {detached: true}
);
现在只能在工具条上点击, 如何在程序中调用 restart 呢
用 document.location.reload(true) 代替是不是不能刷新node的模块?
What about: require('nw.gui').Window.get().reload(3); It will do clean-reload, like the rightmost reload button on toolbar, right?
@f0rmiga No, unfortunately that doesn't work. If your app consists of more than one window, only the window from which that command is run is reloaded. Ideally, App.restart or its equivalent would restart the entire app by shutting down all windows associated with the app.
+1
@james: you could send a notification to that window so it can reload itself too.
micha
2014-02-27 1:11 GMT+01:00 Paul Mandel [email protected]:
+1
— Reply to this email directly or view it on GitHubhttps://github.com/rogerwang/node-webkit/issues/149#issuecomment-36194978 .
+1
+1
+1