从运行的ruby脚本复制数据

时间:2021-02-28 16:24:55

I have a long running ruby script, in Linux, which has some interesting data stored in a hash table. The program does not have any persistence mechanism and I am interested in copying the data from it's hash table. Is there any way to copy data from the memory of a running ruby script?

我有一个长期运行的ruby脚本,在Linux中,它有一些有趣的数据存储在散列表中。程序没有任何持久性机制,我对从它的散列表中复制数据感兴趣。是否有办法从运行的ruby脚本的内存中复制数据?

raj

拉吉

2 个解决方案

#1


7  

It's not for the faint of heart, but there's a tool called Hijack that can give you a live irb prompt to a running ruby process. RubyInside has a very brief rundown and example of how to use it.

它并不适合胆小的人,但是有一个叫做Hijack的工具,它可以为运行中的ruby进程提供一个实时irb提示符。RubyInside有一个非常简短的纲要和如何使用它的例子。

#2


0  

It would be very easy to add a signal handler that responds by dumping a serialized version of your hashtable.

很容易添加一个信号处理程序,该处理程序通过转储您的hashtable的序列化版本来响应。

See Signal.trap.

看到Signal.trap。

#1


7  

It's not for the faint of heart, but there's a tool called Hijack that can give you a live irb prompt to a running ruby process. RubyInside has a very brief rundown and example of how to use it.

它并不适合胆小的人,但是有一个叫做Hijack的工具,它可以为运行中的ruby进程提供一个实时irb提示符。RubyInside有一个非常简短的纲要和如何使用它的例子。

#2


0  

It would be very easy to add a signal handler that responds by dumping a serialized version of your hashtable.

很容易添加一个信号处理程序,该处理程序通过转储您的hashtable的序列化版本来响应。

See Signal.trap.

看到Signal.trap。