将 RPC 功能添加到 Bernstein 的 Daemontools
我是一名来自意大利的计算机科学专业的学生,我必须做一个基于 DJ Bernstein 的 Daemontools 的修改版本的项目,该项目必须在 Unix 下实现远程过程调用。
通常,要使用工具启动守护程序,我会使用以下语法:
svc -u /service/NameOfDaemon
并使用以下语法:
svc -d /service/NameOfDaemon
这样我就可以在本地控制守护程序。这个想法是添加一个代码块,以便能够控制位于远程计算机上的守护程序,这将是理想的语法:
svc -u IP/service/NameOfDaemon
其中 IP 代表用户已知的目标计算机的实际 IP。
这些天我在谷歌上搜索并了解了 RPC 和 DTools,但我有点卡住了,有人可以帮助我开始吗?
也许还有一些适合我的项目的推荐读物?
I'm a Computer Science student from Italy, I have to do a project based on a modified version of the Daemontools Of D.J. Bernstein which has to implement remote procedure calls under Unix.
Normally to get a daemon up with the tools I use this syntax:
svc -u /service/NameOfDaemon
And down with this:
svc -d /service/NameOfDaemon
So I can control a daemon locally. The idea is to add a block of code to be able to control a daemon situated on a remote machine, this will be the ideal syntax:
svc -u IP/service/NameOfDaemon
where IP stands for the actual IP of the target machine, known by the user.
In these days I googled and learned about RPC and DTools but I am a bit stuck, can anyone help me get started?
Perhaps also some recommended reading for my project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Unix 的方式是说:
unix 哲学 是关于创建能够很好地完成一件事并与其他工具协同工作的小工具。
svc
是一个可以控制本地机器上守护进程的工具。ssh
可以在远程计算机上运行工具。不需要其他工具。如果您绝对必须有一个可以控制本地和远程守护进程的命令,那么正如 Chris 建议的那样,您可以编写一个根据需要运行
svc
或ssh
的 shell 脚本。The unix way of doing this is to say:
The unix philosophy is about creating small tools which do one thing well, and work together with other tools.
svc
is a tool which can control daemons on the local machine.ssh
can run tools on remote machines. There is no need for another tool.If you absolutely must have a single command which can control both local and remote daemons, then as Chris suggests, you can write a shell script which runs
svc
orssh
as needed.supervise
使用 Unix 域套接字来接收请求。使用 Unix 域套接字的优点是可以通过通常的文件系统权限来控制对它的访问——在这种情况下,它只允许 root 访问套接字,因此通常必须运行 svc< /code> 作为 root。然而,一旦您通过网络,您就开始必须考虑网络身份验证(除非您希望任何汤姆、迪克和哈利启动和停止您的服务)。如果您能解决这个问题,那么剩下的事情就很简单:
tcpserver
上运行的服务,它可以为您调用远程计算机上的svc
。如果tcpserver
提供的访问控制足以满足您的需要,那么很好;否则你的服务必须处理剩下的事情。tcpserver
命令行上指定-u
)。相反,只需更改supervise
套接字的(组)所有权,以便运行服务的用户可以读取和写入它们。svc
的 shell 脚本。它检查“远程服务器”语法,如果使用,它将连接到您的远程服务(否则只需像往常一样调用 svc)。supervise
uses Unix-domain sockets to receive requests. The advantage of using Unix-domain sockets is that access to it can be controlled via the usual filesystem permissions---in this case, it allows only root to access the socket, hence the reason why you normally must runsvc
as root.However, once you go over the network, you start having to think about network authentication (unless you want any Tom, Dick, and Harry to start and stop your services). If you can solve that, the rest of it is easy:
tcpserver
, that can invokesvc
on the remote machine for you. If the access control provided bytcpserver
is sufficient for you, then well and good; otherwise your service must handle what's left.-u
on thetcpserver
command line). Instead, just change the (group) ownership of yoursupervise
sockets so that they are readable and writeable by the user that your service runs as.svc
. It checks for the "remote server" syntax and if used, it would connect to your remote service (and otherwise just invokesvc
as usual).