nw.js icon indicating copy to clipboard operation
nw.js copied to clipboard

Api suggestion: API.App.restart

Open peters opened this issue 14 years ago • 69 comments

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.

peters avatar Nov 05 '12 19:11 peters

Can't you just refresh the page?

document.location.reload(true)

Ivshti avatar Nov 05 '12 20:11 Ivshti

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?

peters avatar Nov 05 '12 21:11 peters

+1

ibdknox avatar Nov 06 '12 03:11 ibdknox

I'll implement App.restart() after #64 is done.

zcbenz avatar Nov 07 '12 11:11 zcbenz

+1

twrodriguez avatar Jun 02 '13 17:06 twrodriguez

Any thoughts / priority on this restart API? Would be great.

tommoor avatar Jun 10 '13 10:06 tommoor

+1 for a clean restart function

javichi avatar Jul 10 '13 15:07 javichi

Any updates on this feature?

adampetrie avatar Oct 09 '13 14:10 adampetrie

+1 for this!

schme16 avatar Nov 06 '13 07:11 schme16

+1 It would be nice to auto update applications.

rhiokim avatar Nov 06 '13 15:11 rhiokim

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.

tommoor avatar Nov 08 '13 11:11 tommoor

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}
);

semmel avatar Nov 08 '13 20:11 semmel

现在只能在工具条上点击, 如何在程序中调用 restart 呢

用 document.location.reload(true) 代替是不是不能刷新node的模块?

yolio2003 avatar Jan 12 '14 02:01 yolio2003

What about: require('nw.gui').Window.get().reload(3); It will do clean-reload, like the rightmost reload button on toolbar, right?

f0rmiga avatar Feb 04 '14 15:02 f0rmiga

@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.

jamesmortensen avatar Feb 10 '14 09:02 jamesmortensen

+1

paulmand3l avatar Feb 27 '14 00:02 paulmand3l

@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 .

michapixel avatar Feb 27 '14 09:02 michapixel

+1

laggingreflex avatar Mar 16 '14 15:03 laggingreflex

+1

scottgmeadows avatar Mar 17 '14 15:03 scottgmeadows

+1

nbush avatar Mar 17 '14 16:03 nbush