mickle026 480 Posted November 14 Posted November 14 (edited) I have set up an action in a plugin to restart the server after my plugin updates using IApplicationHost, that part I have working just fine. Does anyone know how to detect when the server is restarted in Javascript in order to reload the html page? At the moment my page just sits at the state when restart was sent and i have to manually reload the webpage. I have tried: var Online = true; return function (page, params) { page.addEventListener('offline', (e) => { console.log('Plugin is offline'); Online = false; }); page.addEventListener('online', (e) => { console.log('Plugin is online'); Online = true; }); page.addEventListener('viewshow', () => { then using a do loop function RestartTheServer() { console.log("Restart was Clicked"); ApiClient.getJSON(ApiClient.getUrl('/Test/RestartTheServer')).then(response => { var dat = response; document.getElementById("RestartStatus").innerHTML = dat.Text; checkserverstatus(); }).catch(e => { console.log(e); }); } function checkserverstatus() { do { // do nothing, just wait until online is true } while (Online == false); location.reload(); } Thanks Edited November 14 by mickle026
Luke 38520 Posted November 16 Posted November 16 While the server is restarting you'll have to just periodically ping it in order to determine when it is back up again. /system/ping is a good choice.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now