问题描述
如果我有一个Ruby脚本 Daemon
,顾名思义,它作为守护程序运行,可以监视系统的各个部分并能够执行需要身份验证的命令,例如更改权限,是否有一种简单的方法来拥有第二个ruby脚本,例如 client
,与该脚本进行通信并向其发送命令/询问信息?我正在寻找一种内置的ruby方式,我希望避免在这里构建自己的服务器协议。
If I have a ruby script Daemon
that, as it's name implies, runs as a daemon, monitoring parts of the system and able to perform commands which require authentication, for example changing permissions, is there an easy way to have a second ruby script, say client
, communicate to that script and send it commands / ask for information? I'm looking for a built in ruby way of doing this, I'd prefer to avoid building my own server protocol here.
推荐答案
Ruby为此提供了许多机制,包括您的标准,例如:,,。但是ruby还具有专门用于IPC的更高级别的库,您可以在此处,Drb。我还没有机会玩这个游戏,但是看起来真的很酷。
Ruby provides many mechanisms for this including your standards such as: sockets, pipes, shared memory. But ruby also has a higher level library specifically for IPC which you can checkout Here, Drb. I haven't had a chance to play around with it too much but it looks really cool.
这篇关于两个红宝石工艺之间的通讯可能/容易吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!