优雅重启以保持连接开放

huangapple go评论96阅读模式
英文:

Graceful restart to keep connections open

问题

我确定我看到过一些用Go编写的开源服务器,它能够重新启动并保持连接开放。

我找不到它来学习这个技术。

我知道apache.httpd有apachectl graceful,它可以重新启动并保持连接开放。

一般情况下和在Go中是如何实现的呢?

我认为它必须进行fork,1个退出,2个执行(新的Go应用程序)并通过Fd链接连接。

但是在Go中,我只能找到ForkExec函数。我认为Fork是必需的。
此外,syscall包的文档不是很完善。

英文:

I am sure I saw some open source server written in Go that was able to restart and keep connections open.

I can't find it to learn that technique.

I know apache.httpd has apachectl graceful that restarts and keeps connections open.

How does it done in general and in Go?

I thought it must fork and 1 exit, 2 exec(new go app) and link connections by Fd.

But in Go I can find only ForkExec function. I think Fork is required.
Also syscall package is not very well documented.

答案1

得分: 7

CloseOnExec可能有所帮助,

[FileListener,CloseOnExec和优雅地重启服务器][1]

[Go中TCP服务器的零停机升级][2]

[1]: https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/B98plzvQQN8 "FileListener,CloseOnExec和优雅地重启服务器"
[2]: http://blog.nella.org/?p=879 "Go中TCP服务器的零停机升级"

英文:

CloseOnExec may help,

[FileListener, CloseOnExec and gracefully restarting servers][1]

[Zero Downtime upgrades of TCP servers in Go][2]

[1]: https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/B98plzvQQN8 "FileListener, CloseOnExec and gracefully restarting servers"
[2]: http://blog.nella.org/?p=879 "Zero Downtime upgrades of TCP servers in Go"

huangapple
  • 本文由 发表于 2013年2月13日 07:14:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/14843638.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定