简体   繁体   English

我的守护进程后如何清理?

[英]How do I clean up after my Daemon?

I am running a local instance of HTTP::Daemon using a modified version of the looping structure outlined in the documentation. 我正在使用文档中概述的循环结构的修改版本运行HTTP :: Daemon的本地实例。 I have made it possible to exit the loop at the user's request, but a subsequent execution of my Perl script gives me the error: 我已经可以根据用户的请求退出循环,但后续执行我的Perl脚本会给我错误:

HTTP::Daemon: Address already in use ...propagated at /path/to/script line NNN, line 3. HTTP ::守护程序:已在使用的地址...在/ path /到/脚本行NNN,第3行传播。

What more must I do to be a good citizen and clean up after my Daemon? 在守护进程之后,我还必须做些什么来成为一个好公民并清理干净?

Most likely nothing. 很可能没什么。 The address is in use by leftover connections from the previous instance. 该地址由前一个实例的剩余连接使用。 As soon as they are all shut down, the address will be automatically released. 一旦它们全部关闭,地址将自动释放。

If you want to speed up this process, you can set the SO_REUSEADDR socket option before binding. 如果要加快此过程,可以在绑定之前设置SO_REUSEADDR套接字选项。 See the PERL socket documentation for more details. 有关更多详细信息,请参阅PERL套接字文档。 "if a server dies without outstanding connections the port won't be immediately reusable unless you use the option SO_REUSEADDR using setsockopt() function." “如果服务器在没有未完成连接的情况下死亡,除非您使用setsockopt()函数使用SO_REUSEADDR选项,否则端口将无法立即重复使用。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM