I just successfully added a "Restart server" button to my site's admin page so that I have an easier way to restart after I update my database and script files. And it works nicely!
However, since the button click triggers a regular POST from the browser, the server-side "restart" part of the admin script is never allowed to finish (I assume), since the server restart happens while the script is still running. And this results in a 502 error page being returned to the browser. But worse, this also generates the same 502 error page in the access log, which another script of mine periodically scans for issues...
I thought about just hitting the correct API page (incl. token) with an ajax request from my admin page, but then that's a big cross-site scripting no-no. I could also route the ajax request though a python script on my own site, and let that one do the restart, but while that would solve the in-browser 502 page it would still generate the 502 error in the logs, right?
What are my options here?