开发者

how to detect that localhost web site is closed and then shout apache web server

开发者 https://www.devze.com 2022-12-10 17:32 出处:网络
i need to find away to stop/terminate apache web server that is running on my local pc when i close the site that is running in my local pc(for example http://localhost:8080) or when i close the brows

i need to find away to stop/terminate apache web server that is running on my local pc when i close the site that is running in my local pc (for example http://localhost:8080) or when i close the browser that display/load the localhost site that the local ap开发者_运维技巧ache web server is running . what is the preferred way ?


I don't think this can be done. There's no connection between a browser and the web server after the site's elements have been downloaded, so there's no way for the web server to know whether some browser is still displaying the page. In my opinion what you want to do just can't be done.


there's javascript "onbeforeunload" ... you could have a cgi script running as root terminate apache when the "onbeforeunload" triggers it via ajax.

but that's only really doable if you're the only one visiting that page - otherwise anyones closed window would be the end of apache.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号