[feature request] Automatically set process title to currently running command

未关闭
#991 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
ruby
领域
cli

调研方向

首先调查 IRB 的命令生命周期和 .irbrc 入口点,以及 Ruby 的 Process.setproctitle API。此更改应区分正在主动运行的命令和空闲会话,并提供有意义的进程标题;在可行的情况下,还应包含所请求的空闲时间。

由索引模型根据 Issue 内容生成。

描述

Description

Colleagues of mine regularly SSH into our servers, start an IRB session to look something up, and forget to logout. When they store database query results in local variables, they obviously occupy memory and can't be garbage collected.

It has happened on more than one occasion that I need to manually free resources because half a dozen IRB sessions have multiple GB of memory allocated. I would like to avoid currently active sessions though (i.e. where a user is actively collecting information).

As far as I can tell, I have no information what an IRB process is currently doing. I can't rely on CPU usage, as swapping may induce some load (on Ubuntu 24.04, I have noticed an otherwise idle IRB process to use up to 1% of CPU in top).

It would be useful if IRB would update the process title (Process.setproctitle) to something meaningful, for example:

  • "irb - running ...", when a command is currently running (maybe show the first few characters of the command?)
  • "irb - idle since 13:55", when no command is running

Maybe this is achievable through a piece of code in .irbrc, but I haven't figured out how to do that.

Result of irb_info

irb(main):001> irb_info
Ruby version: 3.2.3
IRB version: irb 1.14.0 (2024-07-06)
InputMethod: RelineInputMethod with Reline 0.5.9
Completion: Autocomplete, RegexpCompletor
.irbrc paths: /home/[redacted]/.irbrc
RUBY_PLATFORM: x86_64-linux-gnu
LANG env: en_US.UTF-8
East Asian Ambiguous Width: 1

This is Ruby/IRB from Ubuntu 24.04 packages.

Terminal Emulator

Tilix on the workstation. This should not matter

Setting Files

Are you using ~/.irbrc and ~/.inputrc?

  • not really, ~/.irbrc includes only commented # IRB.conf[:USE_MULTILINE] = false
主要语言
Ruby
星标
477
派生
165
平均合并
1 天 19 小时
30 天内合并 PR
5

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ruby/irb 的其他 Issue

查看 ruby/irb 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。