多进程 InitScript 逻辑
我正在为我们的一些软件开发初始化脚本,但很难决定如何将它用于特定的部分。
我们有自己开发的软件,负责在网络中传递数据,它是基于标准的发布订阅模型构建的。有一个发布者进程(实际上有两个,用于两个不同的用例)、一个代理进程和一个订阅者进程)。这些进程的任意组合,甚至多个相同进程,都可以在给定的机器上同时运行。我无法决定如何最好地进行配置。由于它可能因盒子而异,因此可能会进入 /etc/sysconfig/pubsub
,并由 initscript 读入。
我唯一需要允许配置的是 (1) 进程名称,它是 log_publish、dir_publish、broker、subscribe 之一,以及 (2) 与该特定进程对应的配置文件。
我希望避免告诉人们如何修改每个盒子的初始化脚本以更改正在运行的进程列表,因此每个盒子的这个独特的配置文件是我能想到的实现这一目标的最佳方法。
我认为这也意味着我必须在盒子上为每个进程提供某种唯一标识符,因为我打算使用大多数 RedHat 初始化脚本使用的 touch /var/lock/subsys/*
方法已经锁定一个进程不运行两次。知道这一点,我知道标识符不能总是随机的,否则它永远不会有效,以防止具有相同配置文件的重复进程(因为,同样,我需要能够使用不同的配置文件运行多个进程) 。
我不知道如何最好地在配置中表示这一点。
I am developing initscripts for some of our software, and am having difficulty deciding how I should use it for a particular piece.
We have homegrown software responsible for passing data around out network, it's built on a standard pubsub model. There is a publisher process (two, actually, for two different use cases), a broker process, and a subscriber process). Any combination of these processes, and even multiple of the same process, can run simultaneously on a given box. I'm having trouble deciding how best to allow this to be configured. Since it can vary from box to box, that will likely go into /etc/sysconfig/pubsub
which will be read in by the initscript.
The only things I will have to allow to be configured is (1) the process name, which is one of log_publish, dir_publish, broker, subscribe, and (2) the configuration file that corresponds to that particular process.
I wish to avoid telling people how to modify the initscript per box in order to change the list of running processes, so this unique configuration file per box is the best way I can come up with to accomplish that.
I assume this also means that I will have to have some kind of unique identifier per process on the box, as I intend to use the touch /var/lock/subsys/*
method that most RedHat initscripts use already to lock a process from running twice. Knowing this, I know the identifier can't always be random, otherwise it will never be effective in order to prevent duplicate processes with the same configuration file (because, again, I need to be able to run multiple processes with different configuration files).
I have no idea how best to represent this in configuration.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的实现方式与 VNC 作为初始化脚本运行时的方式类似。
如果您查看发行版的 vnc init 配置文件(例如 RedHat/CentOS:
/etc/sysconfig/vncservers
),您会看到以下内容:非常简单。您可以定义屏幕编号以及必要时要匹配的参数。
所以现在,我有,例如:
解析这个的大部分逻辑也从 vncserver initscript 中删除,由于篇幅原因我不会在这里发布。
I've implemented this similarly to how VNC does it when run as an initscript.
If you look at your distro's configuration file for vnc init (ex. RedHat/CentOS:
/etc/sysconfig/vncservers
), you see this:Pretty straight forward. You define a screen number, and parameters to match if necessary.
So now, I have, for example:
And most all of the logic for parsing this was also ripped out from the vncserver initscript, which I will not post here for length reasons.
我想说有多个初始化脚本,每个进程类型一个,然后让每个进程的配置确定要生成多少个进程。
I'd say have multiple initscripts, one per process type, and then let the configuration for each determine how many of that process to spawn.