简体   繁体   English

从Azure Web角色,检查进程是否以辅助角色运行

[英]From Azure Web Role, check if a process is running in worker role

I am trying to use 我正在尝试使用

Process[] processes = Process.GetProcessesByName(processName, workerRoleIPAddress);

From my controller to check if a certain process is running in my worker role. 从我的控制器检查某个进程是否正在以我的工作者角色运行。 What is the correct IPAddress to use for the worker role? 用于工作者角色的正确IP地址是什么? Using the IPAddress that the Input Endpoitns use doesn't seem to work. 使用输入Endpoitns使用的IPAddress似乎无效。 Is there a better way to do this? 有一个更好的方法吗?

You are not forced to use the second parameter. 您没有被迫使用第二个参数。 There are two method signatures: 有两种方法签名:

http://msdn.microsoft.com/en-us/library/System.Diagnostics.Process.GetProcessesByName(v=vs.71).aspx http://msdn.microsoft.com/en-us/library/System.Diagnostics.Process.GetProcessesByName(v=vs.71).aspx

  • public static Process[] GetProcessesByName(string);
  • public static Process[] GetProcessesByName(string, string);

I suggest you try to get clear with the first method signature. 我建议您尝试通过第一个方法签名来弄清楚。 After, try to use the IP address. 之后,尝试使用IP地址。

I would try 127.0.0.1 first. 我会先尝试127.0.0.1。 This is the shortest way to try. 这是最短的尝试方法。 Maybe even 'localhost' would be working. 甚至“本地主机”都可以工作。

Then, I don't know this precise in detail, but to ask a process list on a distant computer, this method will need some service running on the distant computer. 然后,我不知道具体的细节,但是要询问远程计算机上的进程列表,此方法将需要在远程计算机上运行的某些服务。 So there might be firewall ports need to be opened opened or a certain demon need to be running on the other computer. 因此,可能需要打开防火墙端口或在另一台计算机上运行某个恶魔。 Asking a list of processes on a distant computer will quickly become a security issue. 询问远程计算机上的进程列表将很快成为安全问题。

I eventually solved the problem by using an Azure Storage table. 我最终通过使用Azure存储表解决了该问题。 I queried the worker role locally using GetProcesssByName() and stored the result in an Azure Storage table. 我使用GetProcesssByName()在本地查询了辅助角色,并将结果存储在Azure存储表中。 I subsequently accessed this table from the web role to read the result. 随后,我从Web角色访问了此表以读取结果。 Care must be taken to delete the older entries from the storage table so we don't assume that older(and currently non-existent) processes are still running. 必须注意从存储表中删除较旧的条目,因此我们不认为较旧(且当前不存在)的进程仍在运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM