TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Runsit – A process manager in Go

57 点作者 armenb将近 11 年前

6 条评论

chubot将近 11 年前
FWIW I also started writing a init-like server in Go. One thing I ran into was that Go&#x27;s APIs sort of coerce you into having an extra thread per process. runsit also has this issue. See line 489 of runsit.go, pasted below.<p>You can do it non-portably in Go by using os.ForkExec and Wait4(-1). The portable exec package assumes you will call Wait(pid), and not Wait(-1), which basically implies using a thread per process. Go&#x27;s runtime isn&#x27;t magic -- if you call libc&#x2F;syscall wait(), an entire thread will be blocked, and the runtime can&#x27;t use it for anything else. In this case this is the lifetime of an entire process, which is forever for server processes.<p>I&#x27;m pretty sure nobody would use a real PID 1 that burned a thread per process (systemd, upstart, etc.). But yes, for most use cases, in the grand scheme of things, it&#x27;s probably not a big deal. I suppose Linux has an O(1) scheduler, although I&#x27;m not quite sure how this affects scheduling (interested in any comments).<p>But this goes to show that portable APIs are awkward and obscure for low level code. Better to use raw Unix APIs for something like an init server. Python and Java have similar problems.<p>IMO all interesting code nowadays is POSIX-like, so we should drop the pretension of portability and simplify our lives. Unix works.<p><pre><code> &#x2F;&#x2F; run in its own goroutine func (in *TaskInstance) awaitDeath() { in.waitErr = in.cmd.Wait() &#x2F;&#x2F; ties up an OS thread for the lifetime of a process ... }</code></pre>
评论 #7925461 未加载
评论 #7924693 未加载
评论 #7925460 未加载
评论 #7924540 未加载
armenb将近 11 年前
Just an introduction: Currently I&#x27;m using runsit as an alternative for supervisord and I&#x27;m happy with it so far. Stdout and stderror of the processes can be queried with a very simple HTTP interface. Runsit watches a config directory for any changes and applies them immediately. Config files are in json format.
评论 #7924248 未加载
评论 #7923912 未加载
gwoo将近 11 年前
I built <a href="https://github.com/gwoo/goforever" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;gwoo&#x2F;goforever</a> which has similar goals. I definitely like some of the ideas in runsit like automatic config watching. I still need to handle log rotation with something like <a href="https://github.com/natefinch/lumberjack" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;natefinch&#x2F;lumberjack</a><p>Thanks for putting this out there.
aktau将近 11 年前
I&#x27;m a big fan of Go and have a few Go binaries running on hundreds of clients (and a few servers) right now. They are being managed by Runit though. Since the names are so similar, did you get inspiration from Runit? And if so, what would be the main differences&#x2F;advantages besides being portable to more platforms (Windows I presume)?<p>@chubot mentions the thread-per-process overhead. Runit does process-per-process so in that aspect Runsit should be a bit lighter. Then again, Runit is extremely tiny, its statically compiled binaries taking up next to nothing. The wait(-1) trick sounds good, but there must be a reason why for example Runit doesn&#x27;t use it, since afaik Runit only runs on POSIX systems.<p>Keep up the good work!<p>EDIT: a web interface, that&#x27;s pretty spiffy! (though I&#x27;ve made something similar work for Runit by querying the status of a service and serving up a dashboard, with a Go webserver of course).
kylered将近 11 年前
In case anyone is interested, we open sourced a process manager and web interface a few months ago.<p><a href="https://github.com/VividCortex/pm" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;VividCortex&#x2F;pm</a> <a href="https://github.com/VividCortex/pm-web" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;VividCortex&#x2F;pm-web</a>
akerl_将近 11 年前
Is there a site for this or some nature of docs?<p>I&#x27;m still searching for a process manager that I can love for use with Docker (I&#x27;ve played with runit and am currently playing with s6), but the total lack of readme or docs makes this link fairly unhelpful.
评论 #7923958 未加载
评论 #7924399 未加载